felipe          Mon Oct  6 14:37:13 2008 UTC

  Added files:                 (Branch: PHP_5_2)
    /php-src/ext/interbase/tests        bug45373.phpt 

  Modified files:              
    /php-src/ext/interbase      ibase_query.c 
  Log:
  - MFH: Fixed bug #45373 (php crash on query with errors in params)
  
  
http://cvs.php.net/viewvc.cgi/php-src/ext/interbase/ibase_query.c?r1=1.23.2.1.2.11&r2=1.23.2.1.2.12&diff_format=u
Index: php-src/ext/interbase/ibase_query.c
diff -u php-src/ext/interbase/ibase_query.c:1.23.2.1.2.11 
php-src/ext/interbase/ibase_query.c:1.23.2.1.2.12
--- php-src/ext/interbase/ibase_query.c:1.23.2.1.2.11   Mon Dec 31 07:20:07 2007
+++ php-src/ext/interbase/ibase_query.c Mon Oct  6 14:37:13 2008
@@ -16,7 +16,7 @@
    +----------------------------------------------------------------------+
  */
 
-/* $Id: ibase_query.c,v 1.23.2.1.2.11 2007/12/31 07:20:07 sebastian Exp $ */
+/* $Id: ibase_query.c,v 1.23.2.1.2.12 2008/10/06 14:37:13 felipe Exp $ */
 
 #ifdef HAVE_CONFIG_H
 #include "config.h"
@@ -1819,16 +1819,17 @@
                if (bind_n != expected_n) {
                        php_error_docref(NULL TSRMLS_CC, (bind_n < expected_n) 
? E_WARNING : E_NOTICE,
                                "Statement expects %d arguments, %d given", 
expected_n, bind_n);
+
                        if (bind_n < expected_n) {
                                break;
                        }
-
-               } else if (bind_n > 0) { /* have variables to bind */
-                       args = (zval ***) do_alloca(ZEND_NUM_ARGS() * 
sizeof(zval **));
+               }
+               
+               /* have variables to bind */
+               args = (zval ***) do_alloca((expected_n + 1) * sizeof(zval **));
        
-                       if (FAILURE == 
zend_get_parameters_array_ex(ZEND_NUM_ARGS(), args)) {
-                               break;
-                       }
+               if (FAILURE == zend_get_parameters_array_ex((expected_n + 1), 
args)) {
+                       break;
                }
 
                /* Have we used this cursor before and it's still open (exec 
proc has no cursor) ? */

http://cvs.php.net/viewvc.cgi/php-src/ext/interbase/tests/bug45373.phpt?view=markup&rev=1.1
Index: php-src/ext/interbase/tests/bug45373.phpt
+++ php-src/ext/interbase/tests/bug45373.phpt
--TEST--
Bug #45373 (php crash on query with errors in params)
--SKIPIF--
<?php include("skipif.inc"); ?>
--FILE--
<?php

        require("interbase.inc");
    
        $db = ibase_connect($test_base);


        $sql = "select * from test1 where i = ? and c = ?";

        $q = ibase_prepare($db, $sql);
        $r = ibase_execute($q, 1, 'test table not created with isql');
        var_dump(ibase_fetch_assoc($r));
        ibase_free_result($r);
        
        $r = ibase_execute($q, 1, 'test table not created with isql', 1);
        var_dump(ibase_fetch_assoc($r));
        ibase_free_result($r);
        
        $r = ibase_execute($q, 1);
        var_dump(ibase_fetch_assoc($r));

?>
--EXPECTF--
array(2) {
  ["I"]=>
  int(1)
  ["C"]=>
  string(32) "test table not created with isql"
}

Notice: ibase_execute(): Statement expects 2 arguments, 3 given in 
%sbug45373.php on line %d
array(2) {
  ["I"]=>
  int(1)
  ["C"]=>
  string(32) "test table not created with isql"
}

Warning: ibase_execute(): Statement expects 2 arguments, 1 given in 
%sbug45373.php on line %d

Warning: ibase_fetch_assoc(): supplied argument is not a valid 
Firebird/InterBase result resource in %sbug45373.php on line %d
bool(false)



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

Reply via email to