From: Andrey Hristov Date: Mon, 3 May 2010 19:02:48 +0000 (+0000) Subject: Handle OOM in mysqlnd_fetch_row_unbuffered_c() X-Git-Tag: php-5.3.3RC1~210 X-Git-Url: https://granicus.if.org/sourcecode?a=commitdiff_plain;h=4a8d751cff925cf7021976ba6b86c0d77f7d2be8;p=php Handle OOM in mysqlnd_fetch_row_unbuffered_c() --- diff --git a/ext/mysqlnd/mysqlnd_result.c b/ext/mysqlnd/mysqlnd_result.c index 7c0e4e1a37..238b699a7c 100644 --- a/ext/mysqlnd/mysqlnd_result.c +++ b/ext/mysqlnd/mysqlnd_result.c @@ -646,27 +646,30 @@ mysqlnd_fetch_row_unbuffered_c(MYSQLND_RES * result TSRMLS_DC) result->conn->stats TSRMLS_CC); retrow = mnd_malloc(result->field_count * sizeof(char *)); + if (retrow) { + for (i = 0; i < field_count; i++, field++, zend_hash_key++) { + zval *data = result->unbuf->last_row_data[i]; + unsigned int len; + + if (Z_TYPE_P(data) != IS_NULL) { + convert_to_string(data); + retrow[i] = Z_STRVAL_P(data); + len = Z_STRLEN_P(data); + } else { + retrow[i] = NULL; + len = 0; + } - for (i = 0; i < field_count; i++, field++, zend_hash_key++) { - zval *data = result->unbuf->last_row_data[i]; - unsigned int len; - - if (Z_TYPE_P(data) != IS_NULL) { - convert_to_string(data); - retrow[i] = Z_STRVAL_P(data); - len = Z_STRLEN_P(data); - } else { - retrow[i] = NULL; - len = 0; - } - - if (lengths) { - lengths[i] = len; - } + if (lengths) { + lengths[i] = len; + } - if (field->max_length < len) { - field->max_length = len; + if (field->max_length < len) { + field->max_length = len; + } } + } else { + SET_OOM_ERROR(result->conn->error_info); } } } else if (ret == FAIL) {