Skip to content

Commit 75fd500

Browse files
committed
fix Pdo\Pgsql running_stmt not being cleared
we unconditionally set it, but conditionally unset it, letting a dangling pointer that was tentatively freed a second time
1 parent 5c6f33d commit 75fd500

File tree

1 file changed

+4
-4
lines changed

1 file changed

+4
-4
lines changed

ext/pdo_pgsql/pgsql_statement.c

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -113,9 +113,10 @@ void pgsql_stmt_finish(pdo_pgsql_stmt *S, int fin_mode)
113113
}
114114

115115
S->is_prepared = false;
116-
if (H->running_stmt == S) {
117-
H->running_stmt = NULL;
118-
}
116+
}
117+
118+
if (H->running_stmt == S && (fin_mode & (FIN_CLOSE|FIN_ABORT))) {
119+
H->running_stmt = NULL;
119120
}
120121
}
121122

@@ -192,7 +193,6 @@ static int pgsql_stmt_execute(pdo_stmt_t *stmt)
192193
* (maybe it will change with pipeline mode in libpq 14?) */
193194
if (H->running_stmt && H->running_stmt->is_unbuffered) {
194195
pgsql_stmt_finish(H->running_stmt, FIN_CLOSE);
195-
H->running_stmt = NULL;
196196
}
197197
/* ensure that we free any previous unfetched results */
198198
pgsql_stmt_finish(S, 0);

0 commit comments

Comments
 (0)