com php-src: Fixed memory leaks: ext/mysql/php_mysql.c

From: Date: Fri, 11 Apr 2014 10:47:53 +0000
Subject: com php-src: Fixed memory leaks: ext/mysql/php_mysql.c
Groups: php.cvs 
Request: Send a blank email to php-cvs+get-77431@lists.php.net to get a copy of this message
Commit: 68c34855afdccd4adbd142c3127ab822c0e877cc Author: Dmitry Stogov <dmitry@zend.com> Fri, 11 Apr 2014 14:47:53 +0400 Parents: f1f3e3c371635f54cb5a43839be6dee320dbe7c9 Branches: phpng Link: http://git.php.net/?p=php-src.git;a=commitdiff;h=68c34855afdccd4adbd142c3127ab822c0e877cc Log: Fixed memory leaks Changed paths: M ext/mysql/php_mysql.c Diff: diff --git a/ext/mysql/php_mysql.c b/ext/mysql/php_mysql.c index 7b0c11c..573c172 100644 --- a/ext/mysql/php_mysql.c +++ b/ext/mysql/php_mysql.c @@ -862,7 +862,7 @@ static void php_mysql_do_connect(INTERNAL_FUNCTION_PARAMETERS, int persistent) /* try to find if we already have this link in our persistent list */ if ((le = zend_hash_find_ptr(&EG(persistent_list), hashed_details)) == NULL) { /* we don't */ - zend_resource new_le; + zval new_le; if (MySG(max_links) != -1 && MySG(num_links) >= MySG(max_links)) { php_error_docref(NULL TSRMLS_CC, E_WARNING, "Too many open links (%ld)", MySG(num_links)); @@ -920,16 +920,17 @@ static void php_mysql_do_connect(INTERNAL_FUNCTION_PARAMETERS, int persistent) mysql_options(mysql->conn, MYSQL_OPT_LOCAL_INFILE, (char *)&MySG(allow_local_infile)); /* hash it up */ - new_le.type = le_plink; - new_le.ptr = mysql; + ZVAL_NEW_PERSISTENT_RES(&new_le, -1, mysql, le_plink); /* avoid bogus memleak report */ phashed = STR_INIT(hashed_details->val, hashed_details->len, 1); - if (zend_hash_update_mem(&EG(persistent_list), phashed, &new_le, sizeof(zend_resource)) == NULL) { + if (zend_hash_update(&EG(persistent_list), phashed, &new_le) == NULL) { + STR_RELEASE(phashed); free(mysql); STR_RELEASE(hashed_details); MYSQL_DO_CONNECT_RETURN_FALSE(); } + STR_RELEASE(phashed); MySG(num_persistent)++; MySG(num_links)++; } else { /* The link is in our list of persistent connections */ @@ -970,7 +971,8 @@ static void php_mysql_do_connect(INTERNAL_FUNCTION_PARAMETERS, int persistent) } ZEND_REGISTER_RESOURCE(return_value, mysql, le_plink); } else { /* non persistent */ - zend_resource *index_ptr, new_index_ptr; + zend_resource *index_ptr; + zval new_index_ptr; /* first we check the hash for the hashed_details key. if it exists, * it should point us to the right offset where the actual mysql link sits. @@ -1055,10 +1057,8 @@ static void php_mysql_do_connect(INTERNAL_FUNCTION_PARAMETERS, int persistent) ZEND_REGISTER_RESOURCE(return_value, mysql, le_link); /* add it to the hash */ - new_index_ptr.ptr = Z_RES_P(return_value); - new_index_ptr.type = le_index_ptr; - - if (zend_hash_update_mem(&EG(regular_list), hashed_details, &new_index_ptr, sizeof(zend_resource)) == NULL) { + ZVAL_NEW_RES(&new_index_ptr, -1, Z_RES_P(return_value), le_index_ptr); + if (zend_hash_update(&EG(regular_list), hashed_details, &new_index_ptr) == NULL) { zval_ptr_dtor(return_value); STR_RELEASE(hashed_details); MYSQL_DO_CONNECT_RETURN_FALSE();

« previous php.cvs (#77431) next »