From: Marc Boeren Date: Tue, 12 Jun 2001 15:32:22 +0000 (+0000) Subject: Fixed bug concerning mysql default_link that got freed too soon (Mc). X-Git-Tag: PRE_GRANULAR_GARBAGE_FIX~68 X-Git-Url: https://granicus.if.org/sourcecode?a=commitdiff_plain;h=92eb51fde2f152c997f371fa5fcf0e3404a76a08;p=php Fixed bug concerning mysql default_link that got freed too soon (Mc). Added the test-case to te connect-test-file (Mc). --- diff --git a/ext/dbx/dbx_mysql.c b/ext/dbx/dbx_mysql.c index d11b2accc9..2102d3a734 100644 --- a/ext/dbx/dbx_mysql.c +++ b/ext/dbx/dbx_mysql.c @@ -51,6 +51,7 @@ int dbx_mysql_connect(zval ** rv, zval ** host, zval ** db, zval ** username, zv /* also close connection */ number_of_arguments=1; arguments[0]=&returned_zval; + zend_list_addref(returned_zval->value.lval); dbx_call_any_function(INTERNAL_FUNCTION_PARAM_PASSTHRU, "mysql_close", &select_db_zval, number_of_arguments, arguments); if (select_db_zval) zval_ptr_dtor(&select_db_zval); zval_ptr_dtor(&returned_zval); @@ -88,6 +89,7 @@ int dbx_mysql_pconnect(zval ** rv, zval ** host, zval ** db, zval ** username, z /* also close connection */ number_of_arguments=1; arguments[0]=&returned_zval; + zend_list_addref(returned_zval->value.lval); dbx_call_any_function(INTERNAL_FUNCTION_PARAM_PASSTHRU, "mysql_close", &select_db_zval, number_of_arguments, arguments); if (select_db_zval) zval_ptr_dtor(&select_db_zval); zval_ptr_dtor(&returned_zval); diff --git a/ext/dbx/tests/003.phpt b/ext/dbx/tests/003.phpt index 254b903878..2c5a8ec762 100644 --- a/ext/dbx/tests/003.phpt +++ b/ext/dbx/tests/003.phpt @@ -79,6 +79,19 @@ else { print_r($dlo); dbx_close($dlo); } +$dlo1 = dbx_connect($module, $host, $database, $username, $password); +$dlo2 = dbx_connect($module, $host, $database, $username, $password); +if ($dlo1!=0 && $dlo2!=0) { + print('multiple connects ok'."\n"); + dbx_close($dlo1); + dbx_close($dlo2); + } +$dlo1 = dbx_connect($module, $host, $database, $username, $password); +$dlo2 = dbx_connect($module, $host, $nonexisting_database, $username, $password); +if ($dlo1!=0 && $dlo2==0) { + print('multiple connects (2nd fails on database-name) ok'."\n"); + dbx_close($dlo1); + } ?> --EXPECT-- connect using string ok @@ -90,4 +103,6 @@ persistent connect using constant ok persistent connect to non-existing database failed, so it's ok persistent connect with false username/password combi failed, so it's ok too many parameters: connect failure works ok -too few parameters: connect failure works ok \ No newline at end of file +too few parameters: connect failure works ok +multiple connects ok +multiple connects (2nd fails on database-name) ok \ No newline at end of file