andrey Thu, 27 May 2010 12:00:48 +0000 Revision: http://svn.php.net/viewvc?view=revision&revision=299843
Log: Fix crashes in the allocator in case of OOM. Changed paths: U php/php-src/branches/PHP_5_3/ext/mysqlnd/mysqlnd_debug.c U php/php-src/trunk/ext/mysqlnd/mysqlnd_debug.c Modified: php/php-src/branches/PHP_5_3/ext/mysqlnd/mysqlnd_debug.c =================================================================== --- php/php-src/branches/PHP_5_3/ext/mysqlnd/mysqlnd_debug.c 2010-05-27 10:45:39 UTC (rev 299842) +++ php/php-src/branches/PHP_5_3/ext/mysqlnd/mysqlnd_debug.c 2010-05-27 12:00:48 UTC (rev 299843) @@ -932,7 +932,7 @@ #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 @@ #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 @@ 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 @@ 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); } Modified: php/php-src/trunk/ext/mysqlnd/mysqlnd_debug.c =================================================================== --- php/php-src/trunk/ext/mysqlnd/mysqlnd_debug.c 2010-05-27 10:45:39 UTC (rev 299842) +++ php/php-src/trunk/ext/mysqlnd/mysqlnd_debug.c 2010-05-27 12:00:48 UTC (rev 299843) @@ -932,7 +932,7 @@ #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 @@ #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 @@ 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 @@ 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); }
-- PHP CVS Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php