Fix GH-9411: PgSQL large object resource is incorrectly closed

Co-authored-by: Christoph M. Becker <cmbecker69@gmx.de>

Closes GH-9411.
This commit is contained in:
Yurun 2022-09-05 14:53:33 +02:00 committed by Christoph M. Becker
parent 81cb005ef7
commit 6ac3f7c84d
No known key found for this signature in database
GPG key ID: D66C9593118BCCB6
5 changed files with 95 additions and 5 deletions

View file

@ -134,6 +134,8 @@ static int pgsql_stmt_execute(pdo_stmt_t *stmt)
pdo_pgsql_db_handle *H = S->H;
ExecStatusType status;
bool in_trans = stmt->dbh->methods->in_transaction(stmt->dbh);
/* ensure that we free any previous unfetched results */
if(S->result) {
PQclear(S->result);
@ -252,6 +254,10 @@ stmt_retry:
stmt->row_count = (zend_long)PQntuples(S->result);
}
if (in_trans && !stmt->dbh->methods->in_transaction(stmt->dbh)) {
pdo_pgsql_close_lob_streams(stmt->dbh);
}
return 1;
}