diff options
| author | Nikita Popov <nikic@php.net> | 2015-04-16 21:00:41 +0200 |
|---|---|---|
| committer | Nikita Popov <nikic@php.net> | 2015-04-16 21:08:29 +0200 |
| commit | 6202e2860d84b7415a9da613e77ac800d64a1a51 (patch) | |
| tree | 57e5dd6b33c59063abcc0b02463c1997448c9048 | |
| parent | 32ab26182b0c24c8d12ac6031e9974cf4f2c4865 (diff) | |
| download | php-git-6202e2860d84b7415a9da613e77ac800d64a1a51.tar.gz | |
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.
| -rw-r--r-- | ext/pdo/pdo_dbh.c | 2 | ||||
| -rw-r--r-- | ext/pdo/pdo_stmt.c | 3 |
2 files changed, 3 insertions, 2 deletions
diff --git a/ext/pdo/pdo_dbh.c b/ext/pdo/pdo_dbh.c index a847ae5103..9029e4a8ea 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 15e489a0bd..3c09609fc6 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; } /* }}} */ |
