cvs: php-src(PHP_5_2) /ext/oci8 oci8.c oci8_lob.c php_oci8_int.h /ext/oci8/tests bug43497.phpt
| From: | Christopher Jones | Date: | Tue, 15 Jan 2008 20:42:13 +0000 |
| Subject: | cvs: php-src(PHP_5_2) /ext/oci8 oci8.c oci8_lob.c php_oci8_int.h /ext/oci8/tests bug43497.phpt | ||
| Groups: | php.cvs | ||
| Request: | Send a blank email to php-cvs+get-47853@lists.php.net to get a copy of this message | ||
sixd Tue Jan 15 20:42:13 2008 UTC
Added files: (Branch: PHP_5_2)
/php-src/ext/oci8/tests bug43497.phpt
Modified files:
/php-src/ext/oci8 oci8.c oci8_lob.c php_oci8_int.h
Log:
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.39&r2=1.269.2.16.2.40&diff_format=u
Index: php-src/ext/oci8/oci8.c
diff -u php-src/ext/oci8/oci8.c:1.269.2.16.2.39 php-src/ext/oci8/oci8.c:1.269.2.16.2.40
--- php-src/ext/oci8/oci8.c:1.269.2.16.2.39 Mon Dec 31 07:20:08 2007
+++ php-src/ext/oci8/oci8.c Tue Jan 15 20:42:13 2008
@@ -26,7 +26,7 @@
+----------------------------------------------------------------------+
*/
-/* $Id: oci8.c,v 1.269.2.16.2.39 2007/12/31 07:20:08 sebastian Exp $ */
+/* $Id: oci8.c,v 1.269.2.16.2.40 2008/01/15 20:42:13 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.39 $");
+ php_info_print_table_row(2, "Revision", "$Revision: 1.269.2.16.2.40 $");
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.15&r2=1.7.2.6.2.16&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.15 php-src/ext/oci8/oci8_lob.c:1.7.2.6.2.16
--- php-src/ext/oci8/oci8_lob.c:1.7.2.6.2.15 Mon Dec 31 07:20:09 2007
+++ php-src/ext/oci8/oci8_lob.c Tue Jan 15 20:42:13 2008
@@ -25,7 +25,7 @@
+----------------------------------------------------------------------+
*/
-/* $Id: oci8_lob.c,v 1.7.2.6.2.15 2007/12/31 07:20:09 sebastian Exp $ */
+/* $Id: oci8_lob.c,v 1.7.2.6.2.16 2008/01/15 20:42:13 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) {
@@ -647,7 +659,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 +673,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.22&r2=1.11.2.6.2.23&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.22 php-src/ext/oci8/php_oci8_int.h:1.11.2.6.2.23
--- php-src/ext/oci8/php_oci8_int.h:1.11.2.6.2.22 Mon Dec 31 07:20:09 2007
+++ php-src/ext/oci8/php_oci8_int.h Tue Jan 15 20:42:13 2008
@@ -25,7 +25,7 @@
+----------------------------------------------------------------------+
*/
-/* $Id: php_oci8_int.h,v 1.11.2.6.2.22 2007/12/31 07:20:09 sebastian Exp $ */
+/* $Id: php_oci8_int.h,v 1.11.2.6.2.23 2008/01/15 20:42:13 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