From: Pierrick Charron Date: Tue, 27 Apr 2010 05:56:56 +0000 (+0000) Subject: Fixed bug #51670 getColumnMeta causes segfault when re-executing query after calling... X-Git-Tag: php-5.2.14RC1~44 X-Git-Url: https://granicus.if.org/sourcecode?a=commitdiff_plain;h=3f159fb7d87e0176a71d70e4d747c0342a2f9026;p=php Fixed bug #51670 getColumnMeta causes segfault when re-executing query after calling nextRowset --- diff --git a/NEWS b/NEWS index f098b56fce..443094fc5d 100644 --- a/NEWS +++ b/NEWS @@ -14,6 +14,8 @@ PHP NEWS - Fixed handling of session variable serialization on certain prefix characters. Reported by Stefan Esser (Ilia) +- Fixed bug #51670 (getColumnMeta causes segfault when re-executing query + after calling nextRowset). (Pierrick) - Fixed bug #51629 (CURLOPT_FOLLOWLOCATION error message is misleading). (Pierre) - Fixed bug #51617 (PDO PGSQL still broken against PostGreSQL < 7.4). diff --git a/ext/pdo/pdo_stmt.c b/ext/pdo/pdo_stmt.c index f3ca75ad5f..ccacdbfc18 100755 --- a/ext/pdo/pdo_stmt.c +++ b/ext/pdo/pdo_stmt.c @@ -2089,6 +2089,8 @@ static int pdo_stmt_do_next_rowset(pdo_stmt_t *stmt TSRMLS_DC) } if (!stmt->methods->next_rowset(stmt TSRMLS_CC)) { + /* Set the executed flag to 0 to reallocate columns on next execute */ + stmt->executed = 0; return 0; } diff --git a/ext/pdo_mysql/tests/bug_51670.phpt b/ext/pdo_mysql/tests/bug_51670.phpt new file mode 100644 index 0000000000..d5387e6c6f --- /dev/null +++ b/ext/pdo_mysql/tests/bug_51670.phpt @@ -0,0 +1,24 @@ +--TEST-- +Bug #51670 (getColumnMeta causes segfault when re-executing query after calling nextRowset) +--SKIPIF-- + +--FILE-- +prepare('SELECT 1 AS num'); +$query->execute(); +if(!is_array($query->getColumnMeta(0))) die('FAIL!'); +$query->nextRowset(); +$query->execute(); +if(!is_array($query->getColumnMeta(0))) die('FAIL!'); +echo 'done!'; +?> +--EXPECTF-- +done! +