]> granicus.if.org Git - php/commitdiff
Handle OOM in mysqlnd_fetch_row_buffered_c()
authorAndrey Hristov <andrey@php.net>
Mon, 3 May 2010 19:09:45 +0000 (19:09 +0000)
committerAndrey Hristov <andrey@php.net>
Mon, 3 May 2010 19:09:45 +0000 (19:09 +0000)
ext/mysqlnd/mysqlnd_result.c

index 238b699a7c3f68ad2d1ebd2cebe5716a8b1beb3a..e8d66a9672ee836c588b4aa14dc822a8e8906b63 100644 (file)
@@ -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");