com php-src: Allocate array of proper size: ext/mysqlnd/mysqlnd _result.c
| From: | Dmitry Stogov | Date: | Wed, 18 Jul 2018 11:49:52 +0000 |
| Subject: | com php-src: Allocate array of proper size: ext/mysqlnd/mysqlnd _result.c | ||
| Groups: | php.cvs | ||
| Request: | Send a blank email to php-cvs+get-102598@lists.php.net to get a copy of this message | ||
Commit: e8a04b387e43d4be5babba9aae442f3abbd0e2d7
Author: Dmitry Stogov <dmitry@zend.com> Wed, 18 Jul 2018 14:49:52 +0300
Parents: 412dd75e057e773e3eeeaeb77a14da655cbd4779
Branches: master
Link: http://git.php.net/?p=php-src.git;a=commitdiff;h=e8a04b387e43d4be5babba9aae442f3abbd0e2d7
Log:
Allocate array of proper size
Changed paths:
M ext/mysqlnd/mysqlnd_result.c
Diff:
diff --git a/ext/mysqlnd/mysqlnd_result.c b/ext/mysqlnd/mysqlnd_result.c
index d9db4c3..38fe116 100644
--- a/ext/mysqlnd/mysqlnd_result.c
+++ b/ext/mysqlnd/mysqlnd_result.c
@@ -1705,6 +1705,7 @@ MYSQLND_METHOD(mysqlnd_res, fetch_into)(MYSQLND_RES * result, const unsigned
int
enum_mysqlnd_extension extension ZEND_FILE_LINE_DC)
{
zend_bool fetched_anything;
+ unsigned int array_size;
DBG_ENTER("mysqlnd_res::fetch_into");
@@ -1712,7 +1713,11 @@ MYSQLND_METHOD(mysqlnd_res, fetch_into)(MYSQLND_RES * result, const unsigned
int
Hint Zend how many elements we will have in the hash. Thus it won't
extend and rehash the hash constantly.
*/
- array_init_size(return_value, mysqlnd_num_fields(result) * 2);
+ array_size = result->field_count;
+ if ((flags & (MYSQLND_FETCH_NUM|MYSQLND_FETCH_ASSOC)) ==
(MYSQLND_FETCH_NUM|MYSQLND_FETCH_ASSOC)) {
+ array_size *= 2;
+ }
+ array_init_size(return_value, array_size);
if (FAIL == result->m.fetch_row(result, (void *)return_value, flags, &fetched_anything)) {
php_error_docref(NULL, E_WARNING, "Error while reading a row");
zend_array_destroy(Z_ARR_P(return_value));