php.net |  support |  documentation |  report a bug |  advanced search |  search howto |  statistics |  random bug |  login
Return to Bug #74856
Patch Patch_new revision 2017-08-17 07:14 UTC by vnkbabu@php.net
Patch fix_pconnect revision 2017-08-16 11:06 UTC by vnkbabu@php.net

Patch Patch_new for ibm_db2 Bug #74856

Patch version 2017-08-17 07:14 UTC

Return to Bug #74856 | Download this patch
Patch Revisions:

Developer: vnkbabu@php.net

--- ibm_db2-1.9.9/ibm_db2.c     2016-04-28 07:31:11.000000000 -0400
+++ ibm_db2.c   2017-08-16 06:51:12.299592770 -0400
@@ -2426,7 +2426,7 @@
     size_t uid_len;
     size_t password_len;
     zend_string *key = NULL;
-    zval *temp = NULL;
+    zend_resource *temp = NULL;
     ZEND_RESOURCE *newEntry;
 #else
     ZEND_RESOURCE newEntry;
@@ -2473,14 +2473,14 @@
                        sprintf(hKey, "__db2_%s.%s.%s", uid, database, password);

 #if PHP_MAJOR_VERSION >= 7
-            temp = zend_hash_str_find_ind(&EG(persistent_list), hKey, hKeyLen );
+            temp = zend_hash_str_find_ptr(&EG(persistent_list), hKey, hKeyLen );
+            if ( temp && temp->type == le_pconn_struct) {
+                conn_res = *pconn_res = (conn_handle *)temp->ptr;

-            if ( temp != NULL ) {
-                entry = Z_RES_P(temp);
 #else
                 if (zend_hash_find(&EG(persistent_list), hKey, hKeyLen, (void **) &entry) == SUCCESS) {
-#endif
                                conn_res = *pconn_res = (conn_handle *) entry->ptr;
+#endif
 #ifndef PASE /* IBM i not support ping (DB2 for i not a daemon-style database, no port, etc.) */
                                /* Need to reinitialize connection? */
                                rc = SQLGetConnectAttr(conn_res->hdbc, SQL_ATTR_PING_DB, (SQLPOINTER)&conn_alive, 0, NULL);
@@ -2785,13 +2785,12 @@
                if (! reused && rc == SQL_SUCCESS) {
                        /* If we created a new persistent connection, add it to the persistent_list */
 #if PHP_MAJOR_VERSION >= 7
-                newEntry = (ZEND_RESOURCE *)ecalloc(1,sizeof(ZEND_RESOURCE));
-                memset(newEntry, 0, sizeof(newEntry));
-                memset(&newEntrydata, 0, sizeof(newEntrydata));
-                ZEND_Z_TYPE_RESOURCE(*newEntry) = le_pconn_struct;
-                newEntry->ptr = conn_res;
-                newEntrydata.value.res = newEntry;
-                if (zend_hash_str_update(&EG(persistent_list), hKey, hKeyLen, &newEntrydata) == NULL) {
+            zend_resource newPersistentRes;
+            newPersistentRes.type = le_pconn_struct;
+            newPersistentRes.ptr = conn_res;
+            GC_REFCOUNT(&newPersistentRes) = 1;
+            if (zend_hash_str_update_mem(&EG(persistent_list), hKey, hKeyLen, &newPersistentRes, sizeof(newPersistentRes)) == NULL) {
+
 #else
                        memset(&newEntry, 0, sizeof(newEntry));
                        Z_TYPE(newEntry) = le_pconn_struct;
 
PHP Copyright © 2001-2024 The PHP Group
All rights reserved.
Last updated: Thu Mar 28 19:01:29 2024 UTC