From cac3520882b947455a3107aac3c401b0604e2fae Mon Sep 17 00:00:00 2001 From: Andrey Hristov Date: Mon, 3 May 2010 19:09:45 +0000 Subject: [PATCH] Handle OOM in mysqlnd_fetch_row_buffered_c() --- ext/mysqlnd/mysqlnd_result.c | 23 +++++++++++++---------- 1 file changed, 13 insertions(+), 10 deletions(-) diff --git a/ext/mysqlnd/mysqlnd_result.c b/ext/mysqlnd/mysqlnd_result.c index 238b699a7c..e8d66a9672 100644 --- a/ext/mysqlnd/mysqlnd_result.c +++ b/ext/mysqlnd/mysqlnd_result.c @@ -939,20 +939,23 @@ mysqlnd_fetch_row_buffered_c(MYSQLND_RES * result TSRMLS_DC) } } - ret = mnd_malloc(result->field_count * sizeof(char *)); + set->data_cursor += result->meta->field_count; + MYSQLND_INC_GLOBAL_STATISTIC(STAT_ROWS_FETCHED_FROM_CLIENT_NORMAL_BUF); - for (i = 0; i < result->field_count; i++, field++, zend_hash_key++) { - zval *data = current_row[i]; + ret = mnd_malloc(result->field_count * sizeof(char *)); + if (ret) { + for (i = 0; i < result->field_count; i++, field++, zend_hash_key++) { + zval *data = current_row[i]; - if (Z_TYPE_P(data) != IS_NULL) { - convert_to_string(data); - ret[i] = Z_STRVAL_P(data); - } else { - ret[i] = NULL; + if (Z_TYPE_P(data) != IS_NULL) { + convert_to_string(data); + ret[i] = Z_STRVAL_P(data); + } else { + ret[i] = NULL; + } } } - set->data_cursor += result->meta->field_count; - MYSQLND_INC_GLOBAL_STATISTIC(STAT_ROWS_FETCHED_FROM_CLIENT_NORMAL_BUF); + /* there is no conn handle in this function thus we can't set OOM in error_info */ } else { set->data_cursor = NULL; DBG_INF("EOF reached"); -- 2.40.0