summaryrefslogtreecommitdiff
path: root/ext/mysqli/mysqli_nonapi.c
diff options
context:
space:
mode:
authorUlf Wendel <uw@php.net>2010-10-01 08:54:16 +0000
committerUlf Wendel <uw@php.net>2010-10-01 08:54:16 +0000
commitbc6e920ebc93a137581d8d9cdd378f1e4f8f6f22 (patch)
treea1eab5cc059f0629d6005fd08207f6a6dedfea55 /ext/mysqli/mysqli_nonapi.c
parentb55d4ecb41d0e5faa09641e6c18e9edf5833c39a (diff)
downloadphp-git-bc6e920ebc93a137581d8d9cdd378f1e4f8f6f22.tar.gz
Fix leak with persistent connections when using mysqli.default_host is used
Diffstat (limited to 'ext/mysqli/mysqli_nonapi.c')
-rw-r--r--ext/mysqli/mysqli_nonapi.c9
1 files changed, 5 insertions, 4 deletions
diff --git a/ext/mysqli/mysqli_nonapi.c b/ext/mysqli/mysqli_nonapi.c
index 4334fc53c9..1d75dac813 100644
--- a/ext/mysqli/mysqli_nonapi.c
+++ b/ext/mysqli/mysqli_nonapi.c
@@ -123,10 +123,6 @@ void mysqli_common_connect(INTERNAL_FUNCTION_PARAMETERS, zend_bool is_real_conne
flags &= ~CLIENT_LOCAL_FILES;
}
}
- if (mysql->mysql && mysqli_resource && (mysqli_resource->status > MYSQLI_STATUS_INITIALIZED || (strlen(SAFE_STR(hostname)) > 2 && !strncasecmp(hostname, "p:", 2)))) {
- /* already connected, we should close the connection */
- php_mysqli_close(mysql, MYSQLI_CLOSE_IMPLICIT, mysqli_resource->status TSRMLS_CC);
- }
if (!socket_len || !socket) {
socket = MyG(default_socket);
@@ -145,6 +141,11 @@ void mysqli_common_connect(INTERNAL_FUNCTION_PARAMETERS, zend_bool is_real_conne
hostname = MyG(default_host);
}
+ if (mysql->mysql && mysqli_resource && (mysqli_resource->status > MYSQLI_STATUS_INITIALIZED || (strlen(SAFE_STR(hostname)) > 2 && !strncasecmp(hostname, "p:", 2)))) {
+ /* already connected, we should close the connection */
+ php_mysqli_close(mysql, MYSQLI_CLOSE_IMPLICIT, mysqli_resource->status TSRMLS_CC);
+ }
+
if (strlen(SAFE_STR(hostname)) > 2 && !strncasecmp(hostname, "p:", 2)) {
hostname += 2;
if (!MyG(allow_persistent)) {