diff options
Diffstat (limited to 'ext/mysqli')
-rw-r--r-- | ext/mysqli/mysqli.c | 6 | ||||
-rw-r--r-- | ext/mysqli/mysqli_api.c | 28 |
2 files changed, 15 insertions, 19 deletions
diff --git a/ext/mysqli/mysqli.c b/ext/mysqli/mysqli.c index f3d5e82309..b33ee41336 100644 --- a/ext/mysqli/mysqli.c +++ b/ext/mysqli/mysqli.c @@ -333,7 +333,7 @@ zval *mysqli_read_property(zval *object, zval *member, int type, void **cache_sl /* }}} */ /* {{{ mysqli_write_property */ -void mysqli_write_property(zval *object, zval *member, zval *value, void **cache_slot) +zval *mysqli_write_property(zval *object, zval *member, zval *value, void **cache_slot) { zval tmp_member; mysqli_object *obj; @@ -353,12 +353,14 @@ void mysqli_write_property(zval *object, zval *member, zval *value, void **cache if (hnd) { hnd->write_func(obj, value); } else { - zend_std_write_property(object, member, value, cache_slot); + value = zend_std_write_property(object, member, value, cache_slot); } if (member == &tmp_member) { zval_ptr_dtor_str(&tmp_member); } + + return value; } /* }}} */ diff --git a/ext/mysqli/mysqli_api.c b/ext/mysqli/mysqli_api.c index 40c7d2982d..e805da9fa7 100644 --- a/ext/mysqli/mysqli_api.c +++ b/ext/mysqli/mysqli_api.c @@ -967,17 +967,11 @@ void mysqli_stmt_fetch_libmysql(INTERNAL_FUNCTION_PARAMETERS) zval *result; /* it must be a reference, isn't it? */ if (Z_ISREF(stmt->result.vars[i])) { - result = Z_REFVAL(stmt->result.vars[i]); + result = stmt->result.vars[i]; } else { - result = &stmt->result.vars[i]; + continue; // but be safe ... } - /* - QQ: Isn't it quite better to call zval_dtor(). What if the user has - assigned a resource, or an array to the bound variable? We are going - to leak probably. zval_dtor() will handle also Unicode/Non-unicode mode. - */ /* Even if the string is of length zero there is one byte alloced so efree() in all cases */ - zval_ptr_dtor(result); if (!stmt->result.is_null[i]) { switch (stmt->result.buf[i].type) { case IS_LONG: @@ -998,16 +992,16 @@ void mysqli_stmt_fetch_libmysql(INTERNAL_FUNCTION_PARAMETERS) } while (--j > 0); tmp[10]= '\0'; /* unsigned int > INT_MAX is 10 digits - ALWAYS */ - ZVAL_STRINGL(result, tmp, 10); + ZEND_TRY_ASSIGN_STRINGL(result, tmp, 10); efree(tmp); break; } #endif } if (stmt->stmt->fields[i].flags & UNSIGNED_FLAG) { - ZVAL_LONG(result, *(unsigned int *)stmt->result.buf[i].val); + ZEND_TRY_ASSIGN_LONG(result, *(unsigned int *)stmt->result.buf[i].val); } else { - ZVAL_LONG(result, *(int *)stmt->result.buf[i].val); + ZEND_TRY_ASSIGN_LONG(result, *(int *)stmt->result.buf[i].val); } break; case IS_DOUBLE: @@ -1024,7 +1018,7 @@ void mysqli_stmt_fetch_libmysql(INTERNAL_FUNCTION_PARAMETERS) dval = *((double *)stmt->result.buf[i].val); } - ZVAL_DOUBLE(result, dval); + ZEND_TRY_ASSIGN_DOUBLE(result, dval); break; } case IS_STRING: @@ -1065,20 +1059,20 @@ void mysqli_stmt_fetch_libmysql(INTERNAL_FUNCTION_PARAMETERS) * use MYSQLI_LL_SPEC. */ snprintf(tmp, sizeof(tmp), (stmt->stmt->fields[i].flags & UNSIGNED_FLAG)? MYSQLI_LLU_SPEC : MYSQLI_LL_SPEC, llval); - ZVAL_STRING(result, tmp); + ZEND_TRY_ASSIGN_STRING(result, tmp); } else { - ZVAL_LONG(result, llval); + ZEND_TRY_ASSIGN_LONG(result, llval); } } else { #if defined(MYSQL_DATA_TRUNCATED) && MYSQL_VERSION_ID > 50002 if (ret == MYSQL_DATA_TRUNCATED && *(stmt->stmt->bind[i].error) != 0) { /* result was truncated */ - ZVAL_STRINGL(result, stmt->result.buf[i].val, stmt->stmt->bind[i].buffer_length); + ZEND_TRY_ASSIGN_STRINGL(result, stmt->result.buf[i].val, stmt->stmt->bind[i].buffer_length); } else { #else { #endif - ZVAL_STRINGL(result, stmt->result.buf[i].val, stmt->result.buf[i].output_len); + ZEND_TRY_ASSIGN_STRINGL(result, stmt->result.buf[i].val, stmt->result.buf[i].output_len); } } break; @@ -1086,7 +1080,7 @@ void mysqli_stmt_fetch_libmysql(INTERNAL_FUNCTION_PARAMETERS) break; } } else { - ZVAL_NULL(result); + ZEND_TRY_ASSIGN_NULL(result); } } } else { |