diff options
-rw-r--r-- | ext/sqlite/sqlite.c | 15 |
1 files changed, 15 insertions, 0 deletions
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)); } /* }}} */ |