summaryrefslogtreecommitdiff
path: root/ext/mysqli/mysqli.c
diff options
context:
space:
mode:
authorGeorg Richter <georg@php.net>2003-02-18 00:00:51 +0000
committerGeorg Richter <georg@php.net>2003-02-18 00:00:51 +0000
commitbc5eb4b3b47b4d6beda5f1149a3712043e51b418 (patch)
tree02a7809063df6adf4a6dff9e7c484b5b087a21d0 /ext/mysqli/mysqli.c
parentbf348326bd629e8f63ed9731881b9988e6cd8fca (diff)
downloadphp-git-bc5eb4b3b47b4d6beda5f1149a3712043e51b418.tar.gz
fixed some leaks when mysql_close will be called before all stmts are freed.
Diffstat (limited to 'ext/mysqli/mysqli.c')
-rw-r--r--ext/mysqli/mysqli.c16
1 files changed, 12 insertions, 4 deletions
diff --git a/ext/mysqli/mysqli.c b/ext/mysqli/mysqli.c
index a72494ff5a..75996eab4d 100644
--- a/ext/mysqli/mysqli.c
+++ b/ext/mysqli/mysqli.c
@@ -43,9 +43,11 @@ void php_clear_stmt_bind(STMT *stmt)
{
unsigned int i;
- if (stmt->stmt && stmt->stmt->mysql->host) {
- mysql_stmt_close(stmt->stmt);
- }
+ /*
+ * we don't need to call mysql_stmt_close here.
+ * in case mysqli_stmt_close wasn't called, all
+ * statements will be freed via mysql_close
+ */
if (stmt->var_cnt) {
for (i = 0; i < stmt->var_cnt; i++) {
@@ -79,6 +81,13 @@ static void mysqli_objects_dtor(void *object, zend_object_handle handle TSRMLS_D
if (intern->zo.ce == mysqli_link_class_entry) {
MYSQL *mysql = (MYSQL *)intern->ptr;
if (mysql) {
+ /*
+ * Don't free mysql if there exist
+ * non closed statements
+ */
+ if (mysql->stmts) {
+ mysql->free_me = 0;
+ }
mysql_close(mysql);
}
} else if (intern->zo.ce == mysqli_stmt_class_entry) { /* stmt object */
@@ -92,7 +101,6 @@ static void mysqli_objects_dtor(void *object, zend_object_handle handle TSRMLS_D
mysql_free_result(res);
}
}
-
zend_objects_destroy_object(object, handle TSRMLS_CC);
}
/* }}} */