]> granicus.if.org Git - php/commitdiff
Fix a memory leak in sqlite3_do_callback.
authorAdam Harvey <aharvey@php.net>
Thu, 24 Sep 2015 12:16:45 +0000 (14:16 +0200)
committerAdam Harvey <aharvey@php.net>
Thu, 24 Sep 2015 12:16:45 +0000 (14:16 +0200)
This was very, very obvious when using a debug build of PHP to build the
manual!

Fixes bug #70571 (Memory leak in sqlite3_do_callback).

NEWS
ext/sqlite3/sqlite3.c

diff --git a/NEWS b/NEWS
index 41ef2ba1e80f55db75c763c10fcf954e2f3e5a3d..92230eabdb648d8f13a07eacffc33c2d3eaa7805 100644 (file)
--- a/NEWS
+++ b/NEWS
@@ -40,6 +40,9 @@ PHP                                                                        NEWS
   . Fixed bug #70529 (Session read causes "String is not zero-terminated" error).
     (Yasuo)
 
+- SQLite3:
+  . Fixed bug #70571 (Memory leak in sqlite3_do_callback). (Adam)
+
 - XMLRPC
   . Fixed bug #70526 (xmlrpc_set_type returns false on success). (Laruence)
 
index 16d37aea9d33ebabbaa63dc8d7a99fca60dd74ca..cc9c5f57a917bfd2ae3d8050b4ea3d00a551f4b7 100644 (file)
@@ -714,7 +714,7 @@ static int sqlite3_do_callback(struct php_sqlite3_fci *fc, zval *cb, int argc, s
                if (Z_ISUNDEF(agg_context->zval_context)) {
                        ZVAL_NULL(&agg_context->zval_context);
                }
-               ZVAL_COPY_VALUE(&zargs[0], &agg_context->zval_context);
+               ZVAL_DUP(&zargs[0], &agg_context->zval_context);
                ZVAL_LONG(&zargs[1], agg_context->row_count);
        }
 
@@ -750,6 +750,10 @@ static int sqlite3_do_callback(struct php_sqlite3_fci *fc, zval *cb, int argc, s
                php_error_docref(NULL, E_WARNING, "An error occurred while invoking the callback");
        }
 
+       if (is_agg) {
+               zval_ptr_dtor(&zargs[0]);
+       }
+
        /* clean up the params */
        if (fake_argc) {
                for (i = is_agg; i < argc + is_agg; i++) {