com php-src: don't pass zero to malloc(): TSRM/TSRM.c
| From: | Anatol Belski | Date: | Tue, 10 Mar 2015 08:10:23 +0000 |
| Subject: | com php-src: don't pass zero to malloc(): TSRM/TSRM.c | ||
| Groups: | php.cvs | ||
| Request: | Send a blank email to php-cvs+get-85427@lists.php.net to get a copy of this message | ||
Commit: fca341699ed851ac40d49a03fcf5d460c6d3c5ed
Author: Anatol Belski <ab@php.net> Mon, 9 Mar 2015 19:34:09 +0100
Parents: a30d328671a93aa7411af2e46176b1bbfd315a93
Branches: master
Link: http://git.php.net/?p=php-src.git;a=commitdiff;h=fca341699ed851ac40d49a03fcf5d460c6d3c5ed
Log:
don't pass zero to malloc()
Changed paths:
M TSRM/TSRM.c
Diff:
diff --git a/TSRM/TSRM.c b/TSRM/TSRM.c
index c3f05a5..386b682 100644
--- a/TSRM/TSRM.c
+++ b/TSRM/TSRM.c
@@ -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;