MFH:Fix for bug#46019 MySQLi::init() leaks memory

This commit is contained in:
Andrey Hristov 2008-09-19 11:38:46 +00:00
parent ba2f507871
commit bf20aa12c7
2 changed files with 25 additions and 1 deletions

View File

@ -1311,7 +1311,13 @@ PHP_FUNCTION(mysqli_info)
PHP_FUNCTION(mysqli_init)
{
MYSQLI_RESOURCE *mysqli_resource;
MY_MYSQL *mysql = (MY_MYSQL *)ecalloc(1, sizeof(MY_MYSQL));
MY_MYSQL *mysql;
if (getThis() && instanceof_function(Z_OBJCE_P(getThis()), mysqli_link_class_entry TSRMLS_CC)) {
return;
}
mysql = (MY_MYSQL *)ecalloc(1, sizeof(MY_MYSQL));
#if !defined(MYSQLI_USE_MYSQLND)
if (!(mysql->mysql = mysql_init(NULL)))

View File

@ -0,0 +1,18 @@
--TEST--
Bug #46109 (MySQLi::init - Memory leaks)
--SKIPIF--
<?php
require_once('skipif.inc');
require_once('skipifconnectfailure.inc');
?>
--FILE--
<?php
include "connect.inc";
$mysqli = new mysqli();
$mysqli->init();
$mysqli->init();
echo "done";
?>
--EXPECTF--
done