From: Andrey Hristov Date: Fri, 23 Dec 2005 22:22:42 +0000 (+0000) Subject: fix small memory leak which emerged two days ago X-Git-Tag: php-5.1.2RC2~88 X-Git-Url: https://granicus.if.org/sourcecode?a=commitdiff_plain;h=eea08af619b674c772dca4172d92b0e159d3c6f8;p=php fix small memory leak which emerged two days ago --- diff --git a/NEWS b/NEWS index b0a1bf09b3..a017bdadaa 100644 --- a/NEWS +++ b/NEWS @@ -43,6 +43,8 @@ PHP NEWS - Fixed many bugs in OCI8. (Tony) - Fixed crash and leak in mysqli when using 4.1.x client libraries and connecting to 5.x server. (Andrey) +- Fixed small leak in mysqli_stmt_fetch() when bound variable was empty + string. (Andrey) - Fixed bug #35760 (sybase_ct doesn't compile on Solaris using old gcc). (Tony) - Fixed bug #35740 (memory leak when including a directory). (Tony) - Fixed bug #35730 (ext/mssql + freetds: Use correct character encoding diff --git a/ext/mysqli/mysqli_api.c b/ext/mysqli/mysqli_api.c index a3a8b0ca48..b4cb8911b9 100644 --- a/ext/mysqli/mysqli_api.c +++ b/ext/mysqli/mysqli_api.c @@ -285,7 +285,7 @@ PHP_FUNCTION(mysqli_stmt_bind_result) bind[ofs].buffer = 0; bind[ofs].is_null = &stmt->result.is_null[ofs]; bind[ofs].buffer_length = 0; - break; + break; case MYSQL_TYPE_SHORT: case MYSQL_TYPE_TINY: @@ -649,7 +649,8 @@ PHP_FUNCTION(mysqli_stmt_fetch) if (!ret) { #endif for (i = 0; i < stmt->result.var_cnt; i++) { - if (stmt->result.vars[i]->type == IS_STRING && stmt->result.vars[i]->value.str.len) { + /* Even if the string is of length zero there is one byte alloced so efree() in all cases */ + if (Z_TYPE_P(stmt->result.vars[i]) == IS_STRING) { efree(stmt->result.vars[i]->value.str.val); } if (!stmt->result.is_null[i]) { @@ -711,7 +712,7 @@ PHP_FUNCTION(mysqli_stmt_fetch) break; } } else { - stmt->result.vars[i]->type = IS_NULL; + ZVAL_NULL(stmt->result.vars[i]); } } } else {