]> granicus.if.org Git - php/commitdiff
fix leak when binding a variable to the same placeholder several times
authorAntony Dovgal <tony2001@php.net>
Tue, 12 Sep 2006 11:42:25 +0000 (11:42 +0000)
committerAntony Dovgal <tony2001@php.net>
Tue, 12 Sep 2006 11:42:25 +0000 (11:42 +0000)
ext/oci8/oci8_statement.c
ext/oci8/tests/debug.phpt

index 03ae250ec4c796ba5c5e24e1c9d3d2f4b3aa1cc3..fabfaa8a3b212b3aa3628ae7f080bf59698bdae7 100644 (file)
@@ -800,7 +800,7 @@ int php_oci_bind_by_name(php_oci_statement *statement, char *name, int name_len,
        /* dvoid *php_oci_collection           = NULL; */
        OCIStmt *oci_stmt               = NULL;
        dvoid *bind_data                = NULL;
-       php_oci_bind bind, *bindp;
+       php_oci_bind bind, *old_bind, *bindp;
        int mode = OCI_DATA_AT_EXEC;
        sb4 value_sz = -1;
 
@@ -900,7 +900,14 @@ int php_oci_bind_by_name(php_oci_statement *statement, char *name, int name_len,
        }
 
        memset((void*)&bind,0,sizeof(php_oci_bind));
-       zend_hash_update(statement->binds, name, name_len + 1, &bind, sizeof(php_oci_bind), (void **)&bindp);
+       if (zend_hash_find(statement->binds, name, name_len + 1, (void **)&old_bind) == SUCCESS) {
+               bindp = old_bind;
+               if (bindp->zval) {
+                       zval_ptr_dtor(&bindp->zval);
+               }
+       } else {
+               zend_hash_update(statement->binds, name, name_len + 1, &bind, sizeof(php_oci_bind), (void **)&bindp);
+       }
        
        bindp->descriptor = oci_desc;
        bindp->statement = oci_stmt;
index cc771d531958e76f11eccbe43fc6aea49569abbf..7bb5d530a57ea31e3910f855d143938ac36f297f 100644 (file)
@@ -28,6 +28,4 @@ OCI8 DEBUG: OCIServerDetach at (%s:%d)
 OCI8 DEBUG: OCIHandleFree at (%s:%d) 
 OCI8 DEBUG: OCIHandleFree at (%s:%d) 
 OCI8 DEBUG: OCIHandleFree at (%s:%d) 
-OCI8 DEBUG: OCIHandleFree at (%s:%d) 
-OCI8 DEBUG: OCIHandleFree at (%s:%d) 
 OCI8 DEBUG: OCIHandleFree at (%s:%d)