From 9efa1d891401aa57685c20fae35f218e2097ea88 Mon Sep 17 00:00:00 2001 From: Antony Dovgal Date: Tue, 31 Jul 2007 19:21:08 +0000 Subject: [PATCH] MFH: fix #42134 (oci_error() returns false after oci_new_collection() fails) --- NEWS | 2 ++ ext/oci8/oci8.c | 9 +++++++++ ext/oci8/oci8_collection.c | 12 +++++++++++- ext/oci8/oci8_interface.c | 9 +++++++++ ext/oci8/oci8_lob.c | 13 +++++++++++-- ext/oci8/oci8_statement.c | 10 ++++++++++ ext/oci8/php_oci8_int.h | 1 - 7 files changed, 52 insertions(+), 4 deletions(-) diff --git a/NEWS b/NEWS index d9bbd4807df..48a613e9a7a 100644 --- a/NEWS +++ b/NEWS @@ -74,6 +74,8 @@ PHP NEWS length). (Ilia) - Fixed bug #42135 (Second call of session_start() causes creation of SID). (Ilia) +- Fixed bug #42134 (oci_error() returns false after oci_new_collection() + fails). (Tony) - Fixed Bug #42112 (deleting a node produces memory corruption). (Rob) - Fixed Bug #42107 (sscanf broken when using %2$s format parameters). (Jani) - Fixed bug #42090 (json_decode causes segmentation fault). (Hannes) diff --git a/ext/oci8/oci8.c b/ext/oci8/oci8.c index 04d4f42a568..5fb8f9ff7ee 100644 --- a/ext/oci8/oci8.c +++ b/ext/oci8/oci8.c @@ -1832,3 +1832,12 @@ static int php_oci_list_helper(zend_rsrc_list_entry *le, void *le_type TSRMLS_DC #endif #endif /* HAVE_OCI8 */ + +/* + * Local variables: + * tab-width: 4 + * c-basic-offset: 4 + * End: + * vim600: noet sw=4 ts=4 fdm=marker + * vim<600: noet sw=4 ts=4 + */ diff --git a/ext/oci8/oci8_collection.c b/ext/oci8/oci8_collection.c index ed9037af78e..dabd90eeaca 100644 --- a/ext/oci8/oci8_collection.c +++ b/ext/oci8/oci8_collection.c @@ -55,7 +55,8 @@ php_oci_collection * php_oci_collection_create(php_oci_connection* connection, c collection->connection = connection; collection->collection = NULL; - + zend_list_addref(collection->connection->rsrc_id); + /* get type handle by name */ PHP_OCI_CALL_RETURN(connection->errcode, OCITypeByName, ( @@ -741,3 +742,12 @@ void php_oci_collection_close(php_oci_collection *collection TSRMLS_DC) } /* }}} */ #endif /* HAVE_OCI8 */ + +/* + * Local variables: + * tab-width: 4 + * c-basic-offset: 4 + * End: + * vim600: noet sw=4 ts=4 fdm=marker + * vim<600: noet sw=4 ts=4 + */ diff --git a/ext/oci8/oci8_interface.c b/ext/oci8/oci8_interface.c index 427a88b7ecd..009ef4d1535 100644 --- a/ext/oci8/oci8_interface.c +++ b/ext/oci8/oci8_interface.c @@ -2169,3 +2169,12 @@ PHP_FUNCTION(oci_new_collection) #endif #endif /* HAVE_OCI8 */ + +/* + * Local variables: + * tab-width: 4 + * c-basic-offset: 4 + * End: + * vim600: noet sw=4 ts=4 fdm=marker + * vim<600: noet sw=4 ts=4 + */ diff --git a/ext/oci8/oci8_lob.c b/ext/oci8/oci8_lob.c index 470b3b44882..9a93ac4e8da 100644 --- a/ext/oci8/oci8_lob.c +++ b/ext/oci8/oci8_lob.c @@ -69,6 +69,8 @@ php_oci_descriptor *php_oci_lob_create (php_oci_connection *connection, long typ descriptor = ecalloc(1, sizeof(php_oci_descriptor)); descriptor->type = type; + descriptor->connection = connection; + zend_list_addref(descriptor->connection->rsrc_id); PHP_OCI_CALL_RETURN(OCI_G(errcode), OCIDescriptorAlloc, (connection->env, (dvoid*)&(descriptor->descriptor), descriptor->type, (size_t) 0, (dvoid **) 0)); @@ -79,8 +81,6 @@ php_oci_descriptor *php_oci_lob_create (php_oci_connection *connection, long typ return NULL; } - descriptor->connection = connection; - PHP_OCI_REGISTER_RESOURCE(descriptor, le_descriptor); descriptor->lob_current_position = 0; @@ -895,3 +895,12 @@ int php_oci_lob_write_tmp (php_oci_descriptor *descriptor, ub1 type, char *data, } /* }}} */ #endif /* HAVE_OCI8 */ + +/* + * Local variables: + * tab-width: 4 + * c-basic-offset: 4 + * End: + * vim600: noet sw=4 ts=4 fdm=marker + * vim<600: noet sw=4 ts=4 + */ diff --git a/ext/oci8/oci8_statement.c b/ext/oci8/oci8_statement.c index 947d7a29780..fa592bc025d 100644 --- a/ext/oci8/oci8_statement.c +++ b/ext/oci8/oci8_statement.c @@ -107,6 +107,7 @@ php_oci_statement *php_oci_statement_create (php_oci_connection *connection, cha statement->connection = connection; statement->has_data = 0; statement->nested = 0; + zend_list_addref(statement->connection->rsrc_id); if (OCI_G(default_prefetch) > 0) { php_oci_statement_set_prefetch(statement, OCI_G(default_prefetch) TSRMLS_CC); @@ -1587,3 +1588,12 @@ php_oci_bind *php_oci_bind_array_helper_date(zval* var, long max_table_length, p } /* }}} */ #endif /* HAVE_OCI8 */ + +/* + * Local variables: + * tab-width: 4 + * c-basic-offset: 4 + * End: + * vim600: noet sw=4 ts=4 fdm=marker + * vim<600: noet sw=4 ts=4 + */ diff --git a/ext/oci8/php_oci8_int.h b/ext/oci8/php_oci8_int.h index 8aacac9cacf..e05a0fb840e 100644 --- a/ext/oci8/php_oci8_int.h +++ b/ext/oci8/php_oci8_int.h @@ -263,7 +263,6 @@ typedef struct { /* php_oci_out_column {{{ */ #define PHP_OCI_REGISTER_RESOURCE(resource, le_resource) \ do { \ resource->id = ZEND_REGISTER_RESOURCE(NULL, resource, le_resource); \ - zend_list_addref(resource->connection->rsrc_id); \ } while (0) #define PHP_OCI_ZVAL_TO_CONNECTION(zval, connection) \