]> granicus.if.org Git - php/commitdiff
Fixed bug #51670 getColumnMeta causes segfault when re-executing query after calling...
authorPierrick Charron <pierrick@php.net>
Tue, 27 Apr 2010 05:56:56 +0000 (05:56 +0000)
committerPierrick Charron <pierrick@php.net>
Tue, 27 Apr 2010 05:56:56 +0000 (05:56 +0000)
NEWS
ext/pdo/pdo_stmt.c
ext/pdo_mysql/tests/bug_51670.phpt [new file with mode: 0644]

diff --git a/NEWS b/NEWS
index 8e3edf0bc842251ad8e1707dc40a869af16e4cbc..808725476b23a25644241d5d5d20aab2c4dc5d05 100644 (file)
--- a/NEWS
+++ b/NEWS
@@ -21,7 +21,9 @@ PHP                                                                        NEWS
   characters. Reported by Stefan Esser (Ilia)
 - Fixed a NULL pointer dereference when processing invalid XML-RPC
   requests (Fixes CVE-2010-0397, bug #51288). (Raphael Geissert)
-- Fixed 64-bit integer overflow in mhash_keygen_s2k(). (Clément LECIGNE, Stas) 
+- Fixed 64-bit integer overflow in mhash_keygen_s2k(). (Clément LECIGNE, Stas)
+- Fixed bug #51670 (getColumnMeta causes segfault when re-executing query
+  after calling nextRowset). (Pierrick)
 - Fixed bug #51647 Certificate file without private key (pk in another file)
   doesn't work. (Andrey)
 - Fixed bug #51629 (CURLOPT_FOLLOWLOCATION error message is misleading).
index f12bfb793a6cd73865b8d2f189a9584320bf394c..5ac2c7ac2d537f5c9315a0c5c03c9700f9fa1640 100755 (executable)
@@ -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 (file)
index 0000000..d5387e6
--- /dev/null
@@ -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!
+