tony2001                Tue Sep 12 11:42:25 2006 UTC

  Modified files:              
    /php-src/ext/oci8   oci8_statement.c 
    /php-src/ext/oci8/tests     debug.phpt 
  Log:
  fix leak when binding a variable to the same placeholder several times
  
  
http://cvs.php.net/viewvc.cgi/php-src/ext/oci8/oci8_statement.c?r1=1.28&r2=1.29&diff_format=u
Index: php-src/ext/oci8/oci8_statement.c
diff -u php-src/ext/oci8/oci8_statement.c:1.28 
php-src/ext/oci8/oci8_statement.c:1.29
--- php-src/ext/oci8/oci8_statement.c:1.28      Thu Aug 31 16:14:43 2006
+++ php-src/ext/oci8/oci8_statement.c   Tue Sep 12 11:42:25 2006
@@ -25,7 +25,7 @@
    +----------------------------------------------------------------------+
 */
 
-/* $Id: oci8_statement.c,v 1.28 2006/08/31 16:14:43 tony2001 Exp $ */
+/* $Id: oci8_statement.c,v 1.29 2006/09/12 11:42:25 tony2001 Exp $ */
 
 
 #ifdef HAVE_CONFIG_H
@@ -800,7 +800,7 @@
        /* 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 @@
        }
 
        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;
http://cvs.php.net/viewvc.cgi/php-src/ext/oci8/tests/debug.phpt?r1=1.4&r2=1.5&diff_format=u
Index: php-src/ext/oci8/tests/debug.phpt
diff -u php-src/ext/oci8/tests/debug.phpt:1.4 
php-src/ext/oci8/tests/debug.phpt:1.5
--- php-src/ext/oci8/tests/debug.phpt:1.4       Tue Mar 28 09:13:35 2006
+++ php-src/ext/oci8/tests/debug.phpt   Tue Sep 12 11:42:25 2006
@@ -28,6 +28,4 @@
 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)

-- 
PHP CVS Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php

Reply via email to