tony2001                Wed Jan 31 10:36:20 2007 UTC

  Modified files:              
    /php-src/ext/oci8   oci8_statement.c php_oci8_int.h 
    /php-src/ext/oci8/tests     oci_execute_segfault.phpt 
  Log:
  fix segfault on re-binding and re-executing a statement
  improve the test
  patch by Chris Jones
  
  
http://cvs.php.net/viewvc.cgi/php-src/ext/oci8/oci8_statement.c?r1=1.41&r2=1.42&diff_format=u
Index: php-src/ext/oci8/oci8_statement.c
diff -u php-src/ext/oci8/oci8_statement.c:1.41 
php-src/ext/oci8/oci8_statement.c:1.42
--- php-src/ext/oci8/oci8_statement.c:1.41      Thu Jan 11 11:58:34 2007
+++ php-src/ext/oci8/oci8_statement.c   Wed Jan 31 10:36:20 2007
@@ -25,7 +25,7 @@
    +----------------------------------------------------------------------+
 */
 
-/* $Id: oci8_statement.c,v 1.41 2007/01/11 11:58:34 tony2001 Exp $ */
+/* $Id: oci8_statement.c,v 1.42 2007/01/31 10:36:20 tony2001 Exp $ */
 
 
 #ifdef HAVE_CONFIG_H
@@ -1147,7 +1147,17 @@
        
        phpbind->out = 1; /* mark as OUT bind */
 
-       if ((Z_TYPE_P(val) == IS_OBJECT) || (Z_TYPE_P(val) == IS_RESOURCE)) {
+       if (Z_TYPE_P(val) == IS_RESOURCE) {
+               retval = OCI_CONTINUE;
+       } else if (Z_TYPE_P(val) == IS_OBJECT) {
+               if (!phpbind->descriptor) {
+                       return OCI_ERROR;
+               }
+               *alenpp = &phpbind->dummy_len;
+               *bufpp = phpbind->descriptor;
+               *piecep = OCI_ONE_PIECE;
+               *rcodepp = &phpbind->retcode;
+               *indpp = &phpbind->indicator;
                retval = OCI_CONTINUE;
        } else { 
                if (UG(unicode)) {
http://cvs.php.net/viewvc.cgi/php-src/ext/oci8/php_oci8_int.h?r1=1.29&r2=1.30&diff_format=u
Index: php-src/ext/oci8/php_oci8_int.h
diff -u php-src/ext/oci8/php_oci8_int.h:1.29 
php-src/ext/oci8/php_oci8_int.h:1.30
--- php-src/ext/oci8/php_oci8_int.h:1.29        Thu Jan 11 11:26:36 2007
+++ php-src/ext/oci8/php_oci8_int.h     Wed Jan 31 10:36:20 2007
@@ -25,7 +25,7 @@
    +----------------------------------------------------------------------+
 */
 
-/* $Id: php_oci8_int.h,v 1.29 2007/01/11 11:26:36 tony2001 Exp $ */
+/* $Id: php_oci8_int.h,v 1.30 2007/01/31 10:36:20 tony2001 Exp $ */
 
 #if HAVE_OCI8
 # ifndef PHP_OCI8_INT_H
@@ -199,6 +199,7 @@
        sb2 indicator;                  /* -1 means NULL */
        ub2 retcode;                    /*  */
        zend_bool out;                  /* OUT bind or not */
+       ub4 dummy_len;                  /* a dummy var to store alenpp value in 
bind OUT callback */
 } php_oci_bind; /* }}} */
 
 typedef struct { /* php_oci_out_column {{{ */
http://cvs.php.net/viewvc.cgi/php-src/ext/oci8/tests/oci_execute_segfault.phpt?r1=1.3&r2=1.4&diff_format=u
Index: php-src/ext/oci8/tests/oci_execute_segfault.phpt
diff -u php-src/ext/oci8/tests/oci_execute_segfault.phpt:1.3 
php-src/ext/oci8/tests/oci_execute_segfault.phpt:1.4
--- php-src/ext/oci8/tests/oci_execute_segfault.phpt:1.3        Tue Dec  6 
19:26:57 2005
+++ php-src/ext/oci8/tests/oci_execute_segfault.phpt    Wed Jan 31 10:36:20 2007
@@ -1,30 +1,54 @@
 --TEST--
-oci_execute() segfault after repeated bind
+oci_execute() segfault after repeated bind of LOB descriptor
 --SKIPIF--
 <?php if (!extension_loaded('oci8')) die("skip no oci8 extension"); ?>
 --FILE--
 <?php
-       
+
 require dirname(__FILE__).'/connect.inc';
 require dirname(__FILE__).'/create_table.inc';
 
 $ora_sql = "INSERT INTO
-                       ".$table_name." (blob, clob)
+                       ".$schema.$table_name." (blob, clob)
                       VALUES (empty_blob(), empty_clob())
                       RETURNING
-                               blob
-                      INTO :v_blob ";
+                               clob
+                      INTO :v_clob ";
+
+$s = oci_parse($c, $ora_sql);
+$clob = oci_new_descriptor($c, OCI_D_LOB);
+oci_bind_by_name($s, ":v_clob", $clob, -1, OCI_B_CLOB);
+oci_execute($s, OCI_DEFAULT);
+var_dump($clob->save("some text data"));
+
+oci_bind_by_name($s, ":v_clob", $clob, -1, OCI_B_CLOB);
+oci_execute($s, OCI_DEFAULT);
+var_dump($clob->save("some more text data"));
 
-$s = oci_parse($c,$ora_sql);
-$blob = oci_new_descriptor($c,OCI_D_LOB);
-oci_bind_by_name($s,":v_blob", $blob,-1,OCI_B_BLOB);
-oci_execute($s);
+$query = 'SELECT clob, DBMS_LOB.GETLENGTH(clob) FROM '.$schema.$table_name.' 
ORDER BY 2';
 
-oci_bind_by_name($s,":v_blob", $blob,-1,OCI_B_BLOB);
-oci_execute($s);
+$s = oci_parse ($c, $query);
+oci_execute($s, OCI_DEFAULT);
+
+while ($arr = oci_fetch_assoc($s)) {
+    $result = $arr['CLOB']->load();
+    var_dump($result);
+}
+
+require dirname(__FILE__).'/drop_table.inc';
 
 echo "Done\n";
 
 ?>
 --EXPECT--
+bool(true)
+bool(true)
+string(14) "some text data"
+string(19) "some more text data"
+Done
+--UEXPECT--
+bool(true)
+bool(true)
+unicode(14) "some text data"
+unicode(19) "some more text data"
 Done

-- 
PHP CVS Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php

Reply via email to