From 32c03b5f3291bac2580a46789d1de60db818cb50 Mon Sep 17 00:00:00 2001 From: Scott MacVicar Date: Sat, 8 Mar 2008 04:18:29 +0000 Subject: MFB: Fixed bug #42203 (Clear SQLite result sets before closing database.) --- ext/sqlite/sqlite.c | 15 +++++++++++++++ 1 file changed, 15 insertions(+) (limited to 'ext/sqlite/sqlite.c') diff --git a/ext/sqlite/sqlite.c b/ext/sqlite/sqlite.c index 24c866a9fe..983000c8c6 100644 --- a/ext/sqlite/sqlite.c +++ b/ext/sqlite/sqlite.c @@ -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)); } /* }}} */ -- cgit v1.2.1