From: Felipe Pena Date: Mon, 6 Oct 2008 14:28:29 +0000 (+0000) Subject: - Fixed bug #45373 (php crash on query with errors in params) X-Git-Tag: BEFORE_HEAD_NS_CHANGE~277 X-Git-Url: https://granicus.if.org/sourcecode?a=commitdiff_plain;h=82eaeb6bfea6b5cea42af68b5c970c59cb1e5ebf;p=php - Fixed bug #45373 (php crash on query with errors in params) --- diff --git a/ext/interbase/ibase_query.c b/ext/interbase/ibase_query.c index e3c0a51740..000fcdecd4 100644 --- a/ext/interbase/ibase_query.c +++ b/ext/interbase/ibase_query.c @@ -1855,16 +1855,17 @@ PHP_FUNCTION(ibase_execute) 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 **), use_heap); + } + + /* have variables to bind */ + args = (zval ***) do_alloca(ZEND_NUM_ARGS() * sizeof(zval **), use_heap); - if (FAILURE == zend_get_parameters_array_ex(ZEND_NUM_ARGS(), args)) { - break; - } + if (FAILURE == zend_get_parameters_array_ex(ZEND_NUM_ARGS(), args)) { + break; } /* Have we used this cursor before and it's still open (exec proc has no cursor) ? */ diff --git a/ext/interbase/tests/bug45373.phpt b/ext/interbase/tests/bug45373.phpt new file mode 100644 index 0000000000..bbaccd1289 --- /dev/null +++ b/ext/interbase/tests/bug45373.phpt @@ -0,0 +1,47 @@ +--TEST-- +Bug #45373 (php crash on query with errors in params) +--SKIPIF-- + +--FILE-- + +--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)