]> granicus.if.org Git - php/commitdiff
fix small memory leak which emerged two days ago
authorAndrey Hristov <andrey@php.net>
Fri, 23 Dec 2005 22:22:42 +0000 (22:22 +0000)
committerAndrey Hristov <andrey@php.net>
Fri, 23 Dec 2005 22:22:42 +0000 (22:22 +0000)
NEWS
ext/mysqli/mysqli_api.c

diff --git a/NEWS b/NEWS
index b0a1bf09b3f49a90684ea3ba9b3ebd459425f5ac..a017bdadaa6c51bf8943b71e9c88c41914304fd0 100644 (file)
--- 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
index a3a8b0ca4867bda56c5184c239ddc8842c895793..b4cb8911b942601f710817e19d71ed6bebbcdbd9 100644 (file)
@@ -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 {