From: Nikita Popov Date: Sun, 12 Feb 2017 11:50:14 +0000 (+0100) Subject: Merge branch 'PHP-7.0' into PHP-7.1 X-Git-Tag: php-7.1.3RC1~40 X-Git-Url: https://granicus.if.org/sourcecode?a=commitdiff_plain;h=98fceaf61eff17d98926f3e6f8f39301066ca001;p=php Merge branch 'PHP-7.0' into PHP-7.1 --- 98fceaf61eff17d98926f3e6f8f39301066ca001 diff --cc ext/mysqlnd/mysqlnd_wireprotocol.c index d5495715e0,6113543e2b..90ae615a1a --- a/ext/mysqlnd/mysqlnd_wireprotocol.c +++ b/ext/mysqlnd/mysqlnd_wireprotocol.c @@@ -1466,6 -1441,6 +1466,7 @@@ php_mysqlnd_read_row_ex(MYSQLND_PFC * p MYSQLND_PACKET_HEADER header; zend_uchar * p = NULL; zend_bool first_iteration = TRUE; ++ size_t prealloc_more_bytes; DBG_ENTER("php_mysqlnd_read_row_ex"); @@@ -1476,15 -1457,10 +1477,16 @@@ for next one if they have 2^24 - 1 sizes. But just read the header of a zero-length byte, don't read the body, there is no such. */ + + /* + We're allocating an extra byte, as php_mysqlnd_rowp_read_text_protocol_aux + needs to be able to append a terminating \0 for atoi/atof. + */ - *data_size = 1; ++ prealloc_more_bytes = 1; + *data_size = 0; while (1) { - if (FAIL == mysqlnd_read_header(conn->net, &header, conn->stats, conn->error_info)) { + if (FAIL == mysqlnd_read_header(pfc, vio, &header, stats, error_info)) { ret = FAIL; break; } @@@ -1493,7 -1469,8 +1495,7 @@@ if (first_iteration) { first_iteration = FALSE; - *buffer = pool->get_chunk(pool, *data_size); - *buffer = result_set_memory_pool->get_chunk( - result_set_memory_pool, *data_size + prealloc_more_bytes); ++ *buffer = pool->get_chunk(pool, *data_size + prealloc_more_bytes); if (!*buffer) { ret = FAIL; break; @@@ -1508,8 -1485,8 +1510,8 @@@ /* We have to realloc the buffer. */ - if (FAIL == pool->resize_chunk(pool, *buffer, *data_size)) { - if (FAIL == (*buffer)->resize_chunk((*buffer), *data_size + prealloc_more_bytes)) { - SET_OOM_ERROR(*conn->error_info); ++ if (FAIL == pool->resize_chunk(pool, *buffer, *data_size + prealloc_more_bytes)) { + SET_OOM_ERROR(error_info); ret = FAIL; break; } @@@ -1528,10 -1505,9 +1530,9 @@@ } } if (ret == FAIL && *buffer) { - (*buffer)->free_chunk((*buffer)); + pool->free_chunk(pool, *buffer); *buffer = NULL; } - (*data_size)--; DBG_RETURN(ret); } /* }}} */