]> granicus.if.org Git - php/commitdiff
don't pass zero to malloc()
authorAnatol Belski <ab@php.net>
Mon, 9 Mar 2015 18:34:09 +0000 (19:34 +0100)
committerAnatol Belski <ab@php.net>
Tue, 10 Mar 2015 08:10:23 +0000 (09:10 +0100)
TSRM/TSRM.c

index c3f05a5842bf0135871b4f783b166a475bb25ae4..386b682ea7447998daac4abe824453b27d88d089 100644 (file)
@@ -277,7 +277,10 @@ static void allocate_new_resource(tsrm_tls_entry **thread_resources_ptr, THREAD_
 
        TSRM_ERROR((TSRM_ERROR_LEVEL_CORE, "Creating data structures for thread %x", thread_id));
        (*thread_resources_ptr) = (tsrm_tls_entry *) malloc(sizeof(tsrm_tls_entry));
-       (*thread_resources_ptr)->storage = (void **) malloc(sizeof(void *)*id_count);
+       (*thread_resources_ptr)->storage = NULL;
+       if (id_count > 0) {
+               (*thread_resources_ptr)->storage = (void **) malloc(sizeof(void *)*id_count);
+       }
        (*thread_resources_ptr)->count = id_count;
        (*thread_resources_ptr)->thread_id = thread_id;
        (*thread_resources_ptr)->next = NULL;