]> granicus.if.org Git - php/commitdiff
MFB: Fixed bug #42203 (Clear SQLite result sets before closing database.)
authorScott MacVicar <scottmac@php.net>
Sat, 8 Mar 2008 04:18:29 +0000 (04:18 +0000)
committerScott MacVicar <scottmac@php.net>
Sat, 8 Mar 2008 04:18:29 +0000 (04:18 +0000)
ext/sqlite/sqlite.c

index 24c866a9fe6c2eb1fa46bcb3013ed112965ea48c..983000c8c60ee051b0100e67ab7b1c40e9ca5c9a 100644 (file)
@@ -403,6 +403,17 @@ static void real_result_dtor(struct php_sqlite_result *res TSRMLS_DC)
        efree(res);
 }
 
+static int _clean_unfinished_results(zend_rsrc_list_entry *le, void *db TSRMLS_DC)
+{
+       if (Z_TYPE_P(le) == le_sqlite_result) {
+               struct php_sqlite_result *res = (struct php_sqlite_result *)le->ptr;
+               if (res->db->rsrc_id == ((struct php_sqlite_db*)db)->rsrc_id) {
+                       real_result_dtor(res TSRMLS_CC);
+               }
+       }
+       return 0;
+}
+
 static ZEND_RSRC_DTOR_FUNC(php_sqlite_result_dtor)
 {
        struct php_sqlite_result *res = (struct php_sqlite_result *)rsrc->ptr;
@@ -1423,6 +1434,10 @@ PHP_FUNCTION(sqlite_close)
                DB_FROM_ZVAL(db, &zdb);
        }
 
+       zend_hash_apply_with_argument(&EG(regular_list),
+               (apply_func_arg_t) _clean_unfinished_results,
+               db TSRMLS_CC);
+
        zend_list_delete(Z_RESVAL_P(zdb));
 }
 /* }}} */