georg Mon Feb 17 19:00:52 2003 EDT Modified files: /php4/ext/mysqli mysqli.c mysqli_api.c Log: fixed some leaks when mysql_close will be called before all stmts are freed. Index: php4/ext/mysqli/mysqli.c diff -u php4/ext/mysqli/mysqli.c:1.4 php4/ext/mysqli/mysqli.c:1.5 --- php4/ext/mysqli/mysqli.c:1.4 Fri Feb 14 15:14:44 2003 +++ php4/ext/mysqli/mysqli.c Mon Feb 17 19:00:51 2003 @@ -15,7 +15,7 @@ | Author: Georg Richter <[EMAIL PROTECTED]> | +----------------------------------------------------------------------+ - $Id: mysqli.c,v 1.4 2003/02/14 20:14:44 iliaa Exp $ + $Id: mysqli.c,v 1.5 2003/02/18 00:00:51 georg Exp $ */ #ifdef HAVE_CONFIG_H @@ -43,9 +43,11 @@ { 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 @@ 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 @@ mysql_free_result(res); } } - zend_objects_destroy_object(object, handle TSRMLS_CC); } /* }}} */ Index: php4/ext/mysqli/mysqli_api.c diff -u php4/ext/mysqli/mysqli_api.c:1.12 php4/ext/mysqli/mysqli_api.c:1.13 --- php4/ext/mysqli/mysqli_api.c:1.12 Sun Feb 16 12:59:30 2003 +++ php4/ext/mysqli/mysqli_api.c Mon Feb 17 19:00:51 2003 @@ -15,7 +15,7 @@ | Author: Georg Richter <[EMAIL PROTECTED]> | +----------------------------------------------------------------------+ - $Id: mysqli_api.c,v 1.12 2003/02/16 17:59:30 iliaa Exp $ + $Id: mysqli_api.c,v 1.13 2003/02/18 00:00:51 georg Exp $ */ #ifdef HAVE_CONFIG_H @@ -384,6 +384,15 @@ } MYSQLI_FETCH_RESOURCE(mysql, MYSQL *, &mysql_link, "mysqli_link"); + + /* + * Don't free initial struct if there exist + * non closed statements + */ + if (mysql->stmts) { + mysql->free_me = 0; + } + mysql_close(mysql); MYSQLI_CLEAR_RESOURCE(&mysql_link); RETURN_TRUE; @@ -1519,7 +1528,7 @@ return; } MYSQLI_FETCH_RESOURCE(stmt, STMT *, &mysql_stmt, "mysqli_stmt"); - + mysql_stmt_close(stmt->stmt); php_clear_stmt_bind(stmt); MYSQLI_CLEAR_RESOURCE(&mysql_stmt); RETURN_TRUE;
-- PHP CVS Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php