summaryrefslogtreecommitdiff
path: root/ext/mysqlnd/mysqlnd_result.c
diff options
context:
space:
mode:
authorUlf Wendel <uw@php.net>2009-09-30 14:39:33 +0000
committerUlf Wendel <uw@php.net>2009-09-30 14:39:33 +0000
commitd79cba2afdb41ae2e9634782adbf2a48d56941d6 (patch)
treec94220600cd95412cd789f360c36b1b8f5e2c9a1 /ext/mysqlnd/mysqlnd_result.c
parent59dc338ac243e4f1d1cc7929a588bb2e85d79006 (diff)
downloadphp-git-d79cba2afdb41ae2e9634782adbf2a48d56941d6.tar.gz
Fixing a leak in mysqlnd when passing invalid fetch modes to mysqlnd.
Diffstat (limited to 'ext/mysqlnd/mysqlnd_result.c')
-rw-r--r--ext/mysqlnd/mysqlnd_result.c19
1 files changed, 4 insertions, 15 deletions
diff --git a/ext/mysqlnd/mysqlnd_result.c b/ext/mysqlnd/mysqlnd_result.c
index 56969944aa..6c3bc14079 100644
--- a/ext/mysqlnd/mysqlnd_result.c
+++ b/ext/mysqlnd/mysqlnd_result.c
@@ -901,13 +901,8 @@ mysqlnd_fetch_row_unbuffered(MYSQLND_RES *result, void *param, unsigned int flag
lengths[i] = len;
}
- /* Forbid ZE to free it, we will clean it */
- Z_ADDREF_P(data);
-
- if ((flags & MYSQLND_FETCH_BOTH) == MYSQLND_FETCH_BOTH) {
- Z_ADDREF_P(data);
- }
if (flags & MYSQLND_FETCH_NUM) {
+ Z_ADDREF_P(data);
zend_hash_next_index_insert(row_ht, &data, sizeof(zval *), NULL);
}
if (flags & MYSQLND_FETCH_ASSOC) {
@@ -918,6 +913,7 @@ mysqlnd_fetch_row_unbuffered(MYSQLND_RES *result, void *param, unsigned int flag
the index is a numeric and convert it to it. This however means constant
hashing of the column name, which is not needed as it can be precomputed.
*/
+ Z_ADDREF_P(data);
if (zend_hash_key->is_numeric == FALSE) {
#if PHP_MAJOR_VERSION >= 6
zend_u_hash_quick_update(Z_ARRVAL_P(row), IS_UNICODE,
@@ -1128,16 +1124,8 @@ mysqlnd_fetch_row_buffered(MYSQLND_RES *result, void *param, unsigned int flags,
for (i = 0; i < result->field_count; i++, field++, zend_hash_key++) {
zval *data = current_row[i];
- /*
- Let us later know what to do with this zval. If ref_count > 1, we will just
- decrease it, otherwise free it. zval_ptr_dtor() make this very easy job.
- */
- Z_ADDREF_P(data);
-
- if ((flags & MYSQLND_FETCH_BOTH) == MYSQLND_FETCH_BOTH) {
- Z_ADDREF_P(data);
- }
if (flags & MYSQLND_FETCH_NUM) {
+ Z_ADDREF_P(data);
zend_hash_next_index_insert(Z_ARRVAL_P(row), &data, sizeof(zval *), NULL);
}
if (flags & MYSQLND_FETCH_ASSOC) {
@@ -1148,6 +1136,7 @@ mysqlnd_fetch_row_buffered(MYSQLND_RES *result, void *param, unsigned int flags,
the index is a numeric and convert it to it. This however means constant
hashing of the column name, which is not needed as it can be precomputed.
*/
+ Z_ADDREF_P(data);
if (zend_hash_key->is_numeric == FALSE) {
#if PHP_MAJOR_VERSION >= 6
zend_u_hash_quick_update(Z_ARRVAL_P(row), IS_UNICODE,