diff options
author | Andrey Hristov <andrey@php.net> | 2010-05-27 12:00:48 +0000 |
---|---|---|
committer | Andrey Hristov <andrey@php.net> | 2010-05-27 12:00:48 +0000 |
commit | 95d4f2ac66059c97172ebd2ed8f08fbaa0c6e390 (patch) | |
tree | 7767512c111e10814106d0dc4b70ee28291b461b /ext/mysqlnd/mysqlnd_debug.c | |
parent | 4de0da5a569eacd80b35e75bf09cf9baf27cc411 (diff) | |
download | php-git-95d4f2ac66059c97172ebd2ed8f08fbaa0c6e390.tar.gz |
Fix crashes in the allocator in case of OOM.
Diffstat (limited to 'ext/mysqlnd/mysqlnd_debug.c')
-rw-r--r-- | ext/mysqlnd/mysqlnd_debug.c | 8 |
1 files changed, 4 insertions, 4 deletions
diff --git a/ext/mysqlnd/mysqlnd_debug.c b/ext/mysqlnd/mysqlnd_debug.c index 232104a89b..4ec5a7e99e 100644 --- a/ext/mysqlnd/mysqlnd_debug.c +++ b/ext/mysqlnd/mysqlnd_debug.c @@ -932,7 +932,7 @@ void * _mysqlnd_malloc(size_t size MYSQLND_MEM_D) #endif DBG_INF_FMT("size=%lu ptr=%p", size, ret); - if (collect_memory_statistics) { + if (ret && collect_memory_statistics) { *(size_t *) ret = size; MYSQLND_INC_GLOBAL_STATISTIC_W_VALUE2(STAT_MEM_MALLOC_COUNT, 1, STAT_MEM_MALLOC_AMOUNT, size); } @@ -963,7 +963,7 @@ void * _mysqlnd_calloc(unsigned int nmemb, size_t size MYSQLND_MEM_D) #endif DBG_INF_FMT("size=%lu ptr=%p", size, ret); - if (collect_memory_statistics) { + if (ret && collect_memory_statistics) { *(size_t *) ret = size; MYSQLND_INC_GLOBAL_STATISTIC_W_VALUE2(STAT_MEM_CALLOC_COUNT, 1, STAT_MEM_CALLOC_AMOUNT, size); } @@ -997,7 +997,7 @@ void * _mysqlnd_realloc(void *ptr, size_t new_size MYSQLND_MEM_D) DBG_INF_FMT("new_ptr=%p", (char*)ret); - if (collect_memory_statistics) { + if (ret && collect_memory_statistics) { *(size_t *) ret = new_size; MYSQLND_INC_GLOBAL_STATISTIC_W_VALUE2(STAT_MEM_REALLOC_COUNT, 1, STAT_MEM_REALLOC_AMOUNT, new_size); } @@ -1082,7 +1082,7 @@ char * _mysqlnd_pestrdup(const char * const ptr, zend_bool persistent MYSQLND_ME ret = pemalloc(tmp_str.len + sizeof(size_t), persistent); memcpy(FAKE_PTR(ret), tmp_str.c, tmp_str.len); - if (collect_memory_statistics) { + if (ret && collect_memory_statistics) { *(size_t *) ret = tmp_str.len; MYSQLND_INC_GLOBAL_STATISTIC(persistent? STAT_MEM_STRDUP_COUNT : STAT_MEM_ESTRDUP_COUNT); } |