com php-src: Fix leak of Pdo object if query() fails: ext/pdo/pdo_dbh.c ext/pdo/pdo_stmt.c
| From: | Nikita Popov | Date: | Thu, 16 Apr 2015 19:08:29 +0000 |
| Subject: | com php-src: Fix leak of Pdo object if query() fails: ext/pdo/pdo_dbh.c ext/pdo/pdo_stmt.c | ||
| Groups: | php.cvs | ||
| Request: | Send a blank email to php-cvs+get-86342@lists.php.net to get a copy of this message | ||
Commit: 6202e2860d84b7415a9da613e77ac800d64a1a51
Author: Nikita Popov <nikic@php.net> Thu, 16 Apr 2015 21:00:41 +0200
Parents: 32ab26182b0c24c8d12ac6031e9974cf4f2c4865
Branches: master
Link: http://git.php.net/?p=php-src.git;a=commitdiff;h=6202e2860d84b7415a9da613e77ac800d64a1a51
Log:
Fix leak of Pdo object if query() fails
Decref the DBH object when storing the errored query statement --
the DBH owns the stmt, so it will live long enough.
Changed paths:
M ext/pdo/pdo_dbh.c
M ext/pdo/pdo_stmt.c
Diff:
diff --git a/ext/pdo/pdo_dbh.c b/ext/pdo/pdo_dbh.c
index a847ae5..9029e4a 100644
--- a/ext/pdo/pdo_dbh.c
+++ b/ext/pdo/pdo_dbh.c
@@ -1114,6 +1114,8 @@ static PHP_METHOD(PDO, query)
/* something broke */
dbh->query_stmt = stmt;
ZVAL_COPY_VALUE(&dbh->query_stmt_zval, return_value);
+ Z_DELREF(stmt->database_object_handle);
+ ZVAL_UNDEF(&stmt->database_object_handle);
PDO_HANDLE_STMT_ERR();
} else {
PDO_HANDLE_DBH_ERR();
diff --git a/ext/pdo/pdo_stmt.c b/ext/pdo/pdo_stmt.c
index 15e489a..3c09609 100644
--- a/ext/pdo/pdo_stmt.c
+++ b/ext/pdo/pdo_stmt.c
@@ -803,7 +803,7 @@ static int do_fetch_func_prepare(pdo_stmt_t *stmt) /* {{{ */
}
/* }}} */
-static int do_fetch_opt_finish(pdo_stmt_t *stmt, int free_ctor_agrs) /* {{{ */
+static void do_fetch_opt_finish(pdo_stmt_t *stmt, int free_ctor_agrs) /* {{{ */
{
/* fci.size is used to check if it is valid */
if (stmt->fetch.cls.fci.size && stmt->fetch.cls.fci.params) {
@@ -826,7 +826,6 @@ static int do_fetch_opt_finish(pdo_stmt_t *stmt, int free_ctor_agrs) /* {{{ */
efree(stmt->fetch.func.values);
stmt->fetch.func.values = NULL;
}
- return 1;
}
/* }}} */