]> granicus.if.org Git - php/commitdiff
- Fixed memory leak on SQLite3Result and SQLite3Stmt when assigning to a reference.
authorFelipe Pena <felipe@php.net>
Fri, 7 Jan 2011 01:11:16 +0000 (01:11 +0000)
committerFelipe Pena <felipe@php.net>
Fri, 7 Jan 2011 01:11:16 +0000 (01:11 +0000)
ext/sqlite3/sqlite3.c
ext/sqlite3/tests/sqlite3_prepare_001.phpt [new file with mode: 0644]

index cc331122423a368e45fa4583182eef868c577751..65f4a231dd02e2aa95cb65ceea60f7b82143d7d8 100644 (file)
@@ -1961,7 +1961,7 @@ static void php_sqlite3_stmt_object_free_storage(void *object TSRMLS_DC) /* {{{
        }
 
        if (intern->db_obj_zval) {
-               Z_DELREF_P(intern->db_obj_zval);
+               zval_ptr_dtor(&intern->db_obj_zval);
        }
 
        zend_object_std_dtor(&intern->zo TSRMLS_CC);
diff --git a/ext/sqlite3/tests/sqlite3_prepare_001.phpt b/ext/sqlite3/tests/sqlite3_prepare_001.phpt
new file mode 100644 (file)
index 0000000..7cd4e4c
--- /dev/null
@@ -0,0 +1,17 @@
+--TEST--
+SQLite3 - memory leak on SQLite3Result and SQLite3Stmt
+--FILE--
+<?php
+
+function test(&$x) {
+       $class = new SQLite3(':memory:');
+       $x = $class->prepare('SELECT 1');
+}
+
+test($foo);
+
+echo "done\n";
+
+?>
+--EXPECTF--
+done