summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorPierrick Charron <pierrick@php.net>2010-04-27 05:56:56 +0000
committerPierrick Charron <pierrick@php.net>2010-04-27 05:56:56 +0000
commit1892d92d68ec62122816a83b019c0d96fd79005f (patch)
treed2d824d74b1a65c52a66c826028e947ba8a4be10
parent6f5f6d2bcad3ea41dcdc4a020d4f58beb4870a76 (diff)
downloadphp-git-1892d92d68ec62122816a83b019c0d96fd79005f.tar.gz
Fixed bug #51670 getColumnMeta causes segfault when re-executing query after calling nextRowset
-rwxr-xr-xext/pdo/pdo_stmt.c2
-rw-r--r--ext/pdo_mysql/tests/bug_51670.phpt24
2 files changed, 26 insertions, 0 deletions
diff --git a/ext/pdo/pdo_stmt.c b/ext/pdo/pdo_stmt.c
index 49199e7f73..1213722bca 100755
--- a/ext/pdo/pdo_stmt.c
+++ b/ext/pdo/pdo_stmt.c
@@ -2080,6 +2080,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--
+<?php
+if (!extension_loaded('pdo') || !extension_loaded('pdo_mysql')) die('skip not loaded');
+require dirname(__FILE__) . '/config.inc';
+require dirname(__FILE__) . '/../../../ext/pdo/tests/pdo_test.inc';
+PDOTest::skip();
+?>
+--FILE--
+<?php
+require dirname(__FILE__) . '/../../../ext/pdo/tests/pdo_test.inc';
+$db = PDOTest::test_factory(dirname(__FILE__) . '/common.phpt');
+$query = $db->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!
+