diff options
author | Christoph M. Becker <cmbecker69@gmx.de> | 2020-10-05 17:46:37 +0200 |
---|---|---|
committer | Christoph M. Becker <cmbecker69@gmx.de> | 2020-10-05 17:46:37 +0200 |
commit | 69ba81d183130b06d52ea1cd4574864ffae5dd84 (patch) | |
tree | 58acdf01ecfb752f1f98fc82b009859365098203 | |
parent | aa405b7da270595d349d0596ad31305a41d4b1c0 (diff) | |
download | php-git-69ba81d183130b06d52ea1cd4574864ffae5dd84.tar.gz |
Fix #46050: odbc_next_result corrupts prepared resource
When resetting the result's values, we also have to reset its numcols.
-rw-r--r-- | NEWS | 1 | ||||
-rw-r--r-- | ext/odbc/php_odbc.c | 1 | ||||
-rw-r--r-- | ext/odbc/tests/bug46050.phpt | 27 |
3 files changed, 29 insertions, 0 deletions
@@ -18,6 +18,7 @@ PHP NEWS (cmb) . Fixed bug #80150 (Failure to fetch error message). (cmb) . Fixed bug #80152 (odbc_execute() moves internal pointer of $params). (cmb) + . Fixed bug #46050 (odbc_next_result corrupts prepared resource). (cmb) - OPcache: . Fixed bug #80083 (Optimizer pass 6 removes variables used for ibm_db2 data diff --git a/ext/odbc/php_odbc.c b/ext/odbc/php_odbc.c index 0722a91e34..1bb832553c 100644 --- a/ext/odbc/php_odbc.c +++ b/ext/odbc/php_odbc.c @@ -2773,6 +2773,7 @@ PHP_FUNCTION(odbc_next_result) } efree(result->values); result->values = NULL; + result->numcols = 0; } result->fetched = 0; diff --git a/ext/odbc/tests/bug46050.phpt b/ext/odbc/tests/bug46050.phpt new file mode 100644 index 0000000000..33564f2170 --- /dev/null +++ b/ext/odbc/tests/bug46050.phpt @@ -0,0 +1,27 @@ +--TEST-- +Bug #46050 (odbc_next_result corrupts prepared resource) +--SKIPIF-- +<?php include 'skipif.inc'; ?> +--FILE-- +<?php +include __DIR__ . "/config.inc"; +$conn = odbc_connect($dsn, $user, $pass); +$stmt = odbc_prepare($conn, "SELECT 1"); +var_dump(odbc_execute($stmt)); +var_dump(odbc_fetch_array($stmt)); +var_dump(odbc_next_result($stmt)); +var_dump(odbc_execute($stmt)); +var_dump(odbc_fetch_array($stmt)); +?> +--EXPECT-- +bool(true) +array(1) { + ["1"]=> + string(1) "1" +} +bool(false) +bool(true) +array(1) { + ["1"]=> + string(1) "1" +} |