MFH: fix #36096 (oci_result() returns garbage after oci_fetch() failed)
authorAntony Dovgal <tony2001@php.net>
Fri, 20 Jan 2006 11:02:49 +0000 (11:02 +0000)
committerAntony Dovgal <tony2001@php.net>
Fri, 20 Jan 2006 11:02:49 +0000 (11:02 +0000)
NEWS
ext/oci8/oci8_statement.c

diff --git a/NEWS b/NEWS
index 39f1ba0a961a30131aa9633777ad09a2d4fc4564..1b8b18ab3e7107683863e1cbb60511f4359ee13e 100644 (file)
--- a/NEWS
+++ b/NEWS
@@ -8,6 +8,8 @@ PHP                                                                        NEWS
   MYSQLI_TYPE_NEWDECIMAL and MYSQLI_TYPE_BIT. FR #36007. (Georg)
 - Fixed imagecolorallocate() and imagecolorallocatelapha() to return FALSE
   on error. (Pierre)
+- Fixed bug #36096 (oci_result() returns garbage after oci_fetch() failed). 
+  (Tony)
 - Fixed bug #36071 (Engine Crash related with 'clone'). (Dmitry)
 - Fixed bug #36055 (possible OCI8 crash in multithreaded environment). (Tony)
 - Fixed bug #36046 (parse_ini_file() miscounts lines in multi-line values).
index 397b1924d03c4bb535df62b2bfe2b41724ebce66..d2d3aab7445eecf8a0ad2a403922efcd0397f8f9 100644 (file)
@@ -165,7 +165,6 @@ int php_oci_statement_fetch(php_oci_statement *statement, ub4 nrows TSRMLS_DC)
                        /* this is exactly what we requested */
                        return 0;
                }
-               
                return 1;
        }
 
@@ -509,7 +508,7 @@ int php_oci_statement_execute(php_oci_statement *statement, ub4 mode TSRMLS_DC)
                                        outcol->storage_size4 *= 3;
                                        
                                        dynamic = OCI_DEFAULT;
-                                       buf = outcol->data = (text *) emalloc(outcol->storage_size4);
+                                       buf = outcol->data = (text *) ecalloc(1, outcol->storage_size4);
                                        break;
                        }
 
@@ -1020,6 +1019,10 @@ php_oci_out_column *php_oci_statement_get_column_helper(INTERNAL_FUNCTION_PARAME
        if (!statement) {
                return NULL;
        }
+
+       if (!statement->has_data) {
+               return NULL;
+       }
        
        if (Z_TYPE_P(column_index) == IS_STRING) {
                column = php_oci_statement_get_column(statement, -1, Z_STRVAL_P(column_index), Z_STRLEN_P(column_index) TSRMLS_CC);