sixd Tue Jan 15 20:44:31 2008 UTC Added files: (Branch: PHP_5_3) /php-src/ext/oci8/tests bug43497.phpt
Modified files: /php-src/ext/oci8 oci8.c oci8_lob.c php_oci8_int.h Log: MFB: fix #43497 (OCI8 XML/getClobVal aka temporary LOBs leak UGA memory) http://cvs.php.net/viewvc.cgi/php-src/ext/oci8/oci8.c?r1=1.269.2.16.2.38.2.3&r2=1.269.2.16.2.38.2.4&diff_format=u Index: php-src/ext/oci8/oci8.c diff -u php-src/ext/oci8/oci8.c:1.269.2.16.2.38.2.3 php-src/ext/oci8/oci8.c:1.269.2.16.2.38.2.4 --- php-src/ext/oci8/oci8.c:1.269.2.16.2.38.2.3 Mon Dec 31 07:17:11 2007 +++ php-src/ext/oci8/oci8.c Tue Jan 15 20:44:31 2008 @@ -26,7 +26,7 @@ +----------------------------------------------------------------------+ */ -/* $Id: oci8.c,v 1.269.2.16.2.38.2.3 2007/12/31 07:17:11 sebastian Exp $ */ +/* $Id: oci8.c,v 1.269.2.16.2.38.2.4 2008/01/15 20:44:31 sixd Exp $ */ /* TODO * * file://localhost/www/docs/oci10/ociaahan.htm#423823 - implement lob_empty() with OCI_ATTR_LOBEMPTY @@ -674,7 +674,7 @@ php_info_print_table_start(); php_info_print_table_row(2, "OCI8 Support", "enabled"); php_info_print_table_row(2, "Version", "1.2.4"); - php_info_print_table_row(2, "Revision", "$Revision: 1.269.2.16.2.38.2.3 $"); + php_info_print_table_row(2, "Revision", "$Revision: 1.269.2.16.2.38.2.4 $"); snprintf(buf, sizeof(buf), "%ld", OCI_G(num_persistent)); php_info_print_table_row(2, "Active Persistent Connections", buf); @@ -1604,6 +1604,7 @@ ub4 lob_length; int column_size; char *lob_buffer; + int lob_fetch_status; if (column->indicator == -1) { /* column is NULL */ ZVAL_NULL(value); @@ -1634,7 +1635,9 @@ if (column->data_type != SQLT_RDD && (mode & PHP_OCI_RETURN_LOBS)) { /* PHP_OCI_RETURN_LOBS means that we want the content of the LOB back instead of the locator */ - if (php_oci_lob_read(descriptor, -1, 0, &lob_buffer, &lob_length TSRMLS_CC)) { + lob_fetch_status = php_oci_lob_read(descriptor, -1, 0, &lob_buffer, &lob_length TSRMLS_CC); + php_oci_temp_lob_close(descriptor); + if (lob_fetch_status) { ZVAL_FALSE(value); return 1; } else { http://cvs.php.net/viewvc.cgi/php-src/ext/oci8/oci8_lob.c?r1=1.7.2.6.2.14.2.1&r2=1.7.2.6.2.14.2.2&diff_format=u Index: php-src/ext/oci8/oci8_lob.c diff -u php-src/ext/oci8/oci8_lob.c:1.7.2.6.2.14.2.1 php-src/ext/oci8/oci8_lob.c:1.7.2.6.2.14.2.2 --- php-src/ext/oci8/oci8_lob.c:1.7.2.6.2.14.2.1 Mon Dec 31 07:17:11 2007 +++ php-src/ext/oci8/oci8_lob.c Tue Jan 15 20:44:31 2008 @@ -25,7 +25,7 @@ +----------------------------------------------------------------------+ */ -/* $Id: oci8_lob.c,v 1.7.2.6.2.14.2.1 2007/12/31 07:17:11 sebastian Exp $ */ +/* $Id: oci8_lob.c,v 1.7.2.6.2.14.2.2 2008/01/15 20:44:31 sixd Exp $ */ @@ -570,7 +570,6 @@ int php_oci_lob_close (php_oci_descriptor *descriptor TSRMLS_DC) { php_oci_connection *connection = descriptor->connection; - int is_temporary; PHP_OCI_CALL_RETURN(connection->errcode, OCILobClose, (connection->svc, connection->err, descriptor->descriptor)); @@ -579,7 +578,21 @@ PHP_OCI_HANDLE_ERROR(connection, connection->errcode); return 1; } + + if (php_oci_temp_lob_close(descriptor)) { + return 1; + } + return 0; +} /* }}} */ + +/* {{{ php_oci_temp_lob_close() + Close Temporary LOB */ +int php_oci_temp_lob_close (php_oci_descriptor *descriptor TSRMLS_DC) +{ + php_oci_connection *connection = descriptor->connection; + int is_temporary; + PHP_OCI_CALL_RETURN(connection->errcode, OCILobIsTemporary, (connection->env,connection->err, descriptor->descriptor, &is_temporary)); if (connection->errcode != OCI_SUCCESS) { @@ -589,7 +602,6 @@ } if (is_temporary) { - PHP_OCI_CALL_RETURN(connection->errcode, OCILobFreeTemporary, (connection->svc, connection->err, descriptor->descriptor)); if (connection->errcode != OCI_SUCCESS) { @@ -601,6 +613,7 @@ return 0; } /* }}} */ + /* {{{ php_oci_lob_flush() Flush buffers for the LOB (only if they have been used) */ int php_oci_lob_flush(php_oci_descriptor *descriptor, long flush_flag TSRMLS_DC) @@ -647,7 +660,6 @@ Close LOB descriptor and free associated resources */ void php_oci_lob_free (php_oci_descriptor *descriptor TSRMLS_DC) { - if (!descriptor || !descriptor->connection) { return; } @@ -662,6 +674,12 @@ php_oci_lob_flush(descriptor, OCI_LOB_BUFFER_FREE TSRMLS_CC); } +#ifdef HAVE_OCI8_TEMP_LOB + if (descriptor->type == OCI_DTYPE_LOB) { + php_oci_temp_lob_close(descriptor); + } +#endif + PHP_OCI_CALL(OCIDescriptorFree, (descriptor->descriptor, descriptor->type)); zend_list_delete(descriptor->connection->rsrc_id); http://cvs.php.net/viewvc.cgi/php-src/ext/oci8/php_oci8_int.h?r1=1.11.2.6.2.21.2.1&r2=1.11.2.6.2.21.2.2&diff_format=u Index: php-src/ext/oci8/php_oci8_int.h diff -u php-src/ext/oci8/php_oci8_int.h:1.11.2.6.2.21.2.1 php-src/ext/oci8/php_oci8_int.h:1.11.2.6.2.21.2.2 --- php-src/ext/oci8/php_oci8_int.h:1.11.2.6.2.21.2.1 Mon Dec 31 07:17:11 2007 +++ php-src/ext/oci8/php_oci8_int.h Tue Jan 15 20:44:31 2008 @@ -25,7 +25,7 @@ +----------------------------------------------------------------------+ */ -/* $Id: php_oci8_int.h,v 1.11.2.6.2.21.2.1 2007/12/31 07:17:11 sebastian Exp $ */ +/* $Id: php_oci8_int.h,v 1.11.2.6.2.21.2.2 2008/01/15 20:44:31 sixd Exp $ */ #if HAVE_OCI8 # ifndef PHP_OCI8_INT_H @@ -342,6 +342,7 @@ int php_oci_lob_copy (php_oci_descriptor *, php_oci_descriptor *, long TSRMLS_DC); #ifdef HAVE_OCI8_TEMP_LOB int php_oci_lob_close (php_oci_descriptor * TSRMLS_DC); +int php_oci_temp_lob_close (php_oci_descriptor * TSRMLS_DC); int php_oci_lob_write_tmp (php_oci_descriptor *, ub1, char *, int TSRMLS_DC); #endif void php_oci_lob_free(php_oci_descriptor * TSRMLS_DC); http://cvs.php.net/viewvc.cgi/php-src/ext/oci8/tests/bug43497.phpt?view=markup&rev=1.1 Index: php-src/ext/oci8/tests/bug43497.phpt +++ php-src/ext/oci8/tests/bug43497.phpt -- PHP CVS Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php