Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Commit dca6d10

Browse files
committed
Fixed bug #70272 (Segfault in pdo_mysql)
1 parent 8df3461 commit dca6d10

4 files changed

Lines changed: 34 additions & 4 deletions

File tree

NEWS

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -46,6 +46,7 @@ PHP NEWS
4646
match). (cmb)
4747

4848
- PDO:
49+
. Fixed bug #70272 (Segfault in pdo_mysql). (Laruence)
4950
. Fixed bug #70221 (persistent sqlite connection + custom function
5051
segfaults). (Laruence)
5152

ext/pdo_mysql/mysql_driver.c

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -147,11 +147,9 @@ static int mysql_handle_closer(pdo_dbh_t *dbh)
147147
if (H) {
148148
if (H->server) {
149149
mysql_close(H->server);
150-
H->server = NULL;
151150
}
152151
if (H->einfo.errmsg) {
153152
pefree(H->einfo.errmsg, dbh->is_persistent);
154-
H->einfo.errmsg = NULL;
155153
}
156154
pefree(H, dbh->is_persistent);
157155
dbh->driver_data = NULL;

ext/pdo_mysql/mysql_statement.c

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -88,8 +88,8 @@ static int pdo_mysql_stmt_dtor(pdo_stmt_t *stmt) /* {{{ */
8888
}
8989
#endif
9090

91-
92-
if (S->H->server) {
91+
if (IS_OBJ_VALID(EG(objects_store).object_buckets[Z_OBJ_HANDLE(stmt->database_object_handle)])
92+
&& (!(GC_FLAGS(Z_OBJ(stmt->database_object_handle)) & IS_OBJ_FREE_CALLED))) {
9393
while (mysql_more_results(S->H->server)) {
9494
MYSQL_RES *res;
9595
if (mysql_next_result(S->H->server) != 0) {

ext/pdo_mysql/tests/bug70272.phpt

Lines changed: 31 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,31 @@
1+
--TEST--
2+
Bug #70272 (Segfault in pdo_mysql)
3+
--SKIPIF--
4+
<?php
5+
require_once(dirname(__FILE__) . DIRECTORY_SEPARATOR . 'skipif.inc');
6+
require_once(dirname(__FILE__) . DIRECTORY_SEPARATOR . 'mysql_pdo_test.inc');
7+
MySQLPDOTest::skip();
8+
?>
9+
--INI--
10+
report_memleaks=off
11+
--FILE--
12+
<?php
13+
$a = new Stdclass();
14+
$a->a = &$a;
15+
require_once(dirname(__FILE__) . DIRECTORY_SEPARATOR . 'mysql_pdo_test.inc');
16+
17+
$dummy = new StdClass();
18+
19+
$db = PDOTest::test_factory(dirname(__FILE__) . '/common.phpt');
20+
$dummy = NULL;
21+
22+
$a->c = $db;
23+
$a->b = $db->prepare("select 1");
24+
$a->d = $db->prepare("select 2");
25+
$a->e = $db->prepare("select 3");
26+
$a->f = $db->prepare("select 4");
27+
gc_disable();
28+
?>
29+
okey
30+
--EXPECT--
31+
okey

0 commit comments

Comments
 (0)