summaryrefslogtreecommitdiff
path: root/ext/mysqlnd/mysqlnd_debug.c
diff options
context:
space:
mode:
authorAndrey Hristov <andrey@php.net>2010-05-21 13:06:52 +0000
committerAndrey Hristov <andrey@php.net>2010-05-21 13:06:52 +0000
commitef1eeff882ed39ffa5a36a6ed0101e942a60e091 (patch)
tree60822818419e99a58da735bef5a1611b4f5cf5b3 /ext/mysqlnd/mysqlnd_debug.c
parent9c90bf42c1cb0db72fddfacaebd1609246006a90 (diff)
downloadphp-git-ef1eeff882ed39ffa5a36a6ed0101e942a60e091.tar.gz
When OOM hits the wire, don't crash.
Diffstat (limited to 'ext/mysqlnd/mysqlnd_debug.c')
-rw-r--r--ext/mysqlnd/mysqlnd_debug.c14
1 files changed, 7 insertions, 7 deletions
diff --git a/ext/mysqlnd/mysqlnd_debug.c b/ext/mysqlnd/mysqlnd_debug.c
index 0df48551e5..0b8a359726 100644
--- a/ext/mysqlnd/mysqlnd_debug.c
+++ b/ext/mysqlnd/mysqlnd_debug.c
@@ -1,4 +1,4 @@
-;/*
+/*
+----------------------------------------------------------------------+
| PHP Version 5 |
+----------------------------------------------------------------------+
@@ -679,7 +679,7 @@ void * _mysqlnd_emalloc(size_t size MYSQLND_MEM_D)
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_EMALLOC_COUNT, 1, STAT_MEM_EMALLOC_AMOUNT, size);
}
@@ -711,7 +711,7 @@ void * _mysqlnd_pemalloc(size_t size, zend_bool persistent MYSQLND_MEM_D)
DBG_INF_FMT("size=%lu ptr=%p persistent=%d", size, ret, persistent);
- if (collect_memory_statistics) {
+ if (ret && collect_memory_statistics) {
enum mysqlnd_collected_stats s1 = persistent? STAT_MEM_MALLOC_COUNT:STAT_MEM_EMALLOC_COUNT;
enum mysqlnd_collected_stats s2 = persistent? STAT_MEM_MALLOC_AMOUNT:STAT_MEM_EMALLOC_AMOUNT;
*(size_t *) ret = size;
@@ -747,7 +747,7 @@ void * _mysqlnd_ecalloc(unsigned int nmemb, size_t size MYSQLND_MEM_D)
DBG_INF_FMT("after : %lu", zend_memory_usage(FALSE TSRMLS_CC));
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_ECALLOC_COUNT, 1, STAT_MEM_ECALLOC_AMOUNT, size);
}
@@ -779,7 +779,7 @@ void * _mysqlnd_pecalloc(unsigned int nmemb, size_t size, zend_bool persistent M
DBG_INF_FMT("size=%lu ptr=%p", size, ret);
- if (collect_memory_statistics) {
+ if (ret && collect_memory_statistics) {
enum mysqlnd_collected_stats s1 = persistent? STAT_MEM_CALLOC_COUNT:STAT_MEM_ECALLOC_COUNT;
enum mysqlnd_collected_stats s2 = persistent? STAT_MEM_CALLOC_AMOUNT:STAT_MEM_ECALLOC_AMOUNT;
*(size_t *) ret = size;
@@ -815,7 +815,7 @@ void * _mysqlnd_erealloc(void *ptr, size_t new_size MYSQLND_MEM_D)
#endif
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_EREALLOC_COUNT, 1, STAT_MEM_EREALLOC_AMOUNT, new_size);
}
@@ -849,7 +849,7 @@ void * _mysqlnd_perealloc(void *ptr, size_t new_size, zend_bool persistent MYSQL
DBG_INF_FMT("new_ptr=%p", (char*)ret);
- if (collect_memory_statistics) {
+ if (ret && collect_memory_statistics) {
enum mysqlnd_collected_stats s1 = persistent? STAT_MEM_REALLOC_COUNT:STAT_MEM_EREALLOC_COUNT;
enum mysqlnd_collected_stats s2 = persistent? STAT_MEM_REALLOC_AMOUNT:STAT_MEM_EREALLOC_AMOUNT;
*(size_t *) ret = new_size;