mirror of
https://github.com/php/php-src.git
synced 2024-12-03 06:44:07 +08:00
MFH:Fix for bug#46019 MySQLi::init() leaks memory
This commit is contained in:
parent
ba2f507871
commit
bf20aa12c7
@ -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)))
|
||||
|
18
ext/mysqli/tests/bug46109.phpt
Normal file
18
ext/mysqli/tests/bug46109.phpt
Normal 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
|
Loading…
Reference in New Issue
Block a user