php.net |  support |  documentation |  report a bug |  advanced search |  search howto |  statistics |  random bug |  login
Return to Bug #66762
Patch mysqli-protect-link.patch revision 2014-02-25 07:44 UTC by remi@php.net
revision 2014-02-25 07:32 UTC by remi@php.net
revision 2014-02-24 18:21 UTC by remi@php.net
revision 2014-02-24 16:35 UTC by remi@php.net

Patch mysqli-protect-link.patch for MySQLi related Bug #66762

Patch version 2014-02-24 16:35 UTC

Return to Bug #66762 | Download this patch
This patch is obsolete

Obsoleted by patches:

Patch Revisions:

Developer: remi@php.net

diff -ru ext/mysqli.old/mysqli_api.c ext/mysqli/mysqli_api.c
--- ext/mysqli.old/mysqli_api.c	2014-02-05 11:00:36.000000000 +0100
+++ ext/mysqli/mysqli_api.c	2014-02-24 17:30:05.962796158 +0100
@@ -1868,6 +1868,9 @@
 		MYSQLI_REPORT_MYSQL_ERROR(mysql->mysql);
 		efree(stmt);
 		RETURN_FALSE;
+	} else {
+		stmt->link_handle = Z_OBJ_HANDLE(*mysql_link);
+		zend_objects_store_add_ref_by_handle(stmt->link_handle);
 	}
 
 	mysqli_resource = (MYSQLI_RESOURCE *)ecalloc (1, sizeof(MYSQLI_RESOURCE));
@@ -2413,6 +2416,8 @@
 		efree(stmt);
 		RETURN_FALSE;
 	}
+	stmt->link_handle = Z_OBJ_HANDLE(*mysql_link);
+	zend_objects_store_add_ref_by_handle(stmt->link_handle);
 
 	mysqli_resource = (MYSQLI_RESOURCE *)ecalloc (1, sizeof(MYSQLI_RESOURCE));
 	mysqli_resource->status = MYSQLI_STATUS_INITIALIZED;
diff -ru ext/mysqli.old/mysqli.c ext/mysqli/mysqli.c
--- ext/mysqli.old/mysqli.c	2014-02-05 11:00:36.000000000 +0100
+++ ext/mysqli/mysqli.c	2014-02-24 17:30:47.903105654 +0100
@@ -181,6 +181,9 @@
 	if (stmt->query) {
 		efree(stmt->query);
 	}
+	if (stmt->link_handle) {
+	    zend_objects_store_del_ref_by_handle(stmt->link_handle TSRMLS_CC);
+	}
 	efree(stmt);
 }
 /* }}} */
@@ -1068,6 +1071,9 @@
 	if (!stmt->stmt) {
 		efree(stmt);
 		RETURN_FALSE;
+	} else {
+		stmt->link_handle = Z_OBJ_HANDLE(*mysql_link);
+		zend_objects_store_add_ref_by_handle(stmt->link_handle);
 	}
 
 	mysqli_resource = (MYSQLI_RESOURCE *)ecalloc (1, sizeof(MYSQLI_RESOURCE));
diff -ru ext/mysqli.old/php_mysqli_structs.h ext/mysqli/php_mysqli_structs.h
--- ext/mysqli.old/php_mysqli_structs.h	2014-02-05 11:00:36.000000000 +0100
+++ ext/mysqli/php_mysqli_structs.h	2014-02-24 17:28:08.187924703 +0100
@@ -116,6 +116,7 @@
 	BIND_BUFFER	param;
 	BIND_BUFFER	result;
 	char		*query;
+	zend_object_handle link_handle;
 } MY_STMT;
 
 typedef struct {
 
PHP Copyright © 2001-2015 The PHP Group
All rights reserved.
Last updated: Mon Aug 31 06:01:33 2015 UTC