From: Antony Dovgal Date: Tue, 12 Sep 2006 11:42:25 +0000 (+0000) Subject: fix leak when binding a variable to the same placeholder several times X-Git-Tag: RELEASE_1_0_0RC1~1693 X-Git-Url: https://granicus.if.org/sourcecode?a=commitdiff_plain;h=0a5cb315375568364fe9b86a5e7a9480036eada1;p=php fix leak when binding a variable to the same placeholder several times --- diff --git a/ext/oci8/oci8_statement.c b/ext/oci8/oci8_statement.c index 03ae250ec4..fabfaa8a3b 100644 --- a/ext/oci8/oci8_statement.c +++ b/ext/oci8/oci8_statement.c @@ -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; diff --git a/ext/oci8/tests/debug.phpt b/ext/oci8/tests/debug.phpt index cc771d5319..7bb5d530a5 100644 --- a/ext/oci8/tests/debug.phpt +++ b/ext/oci8/tests/debug.phpt @@ -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)