Skip to content

Commit a85e3ba

Browse files
committed
In psql, avoid leaking a PGresult after a query is cancelled.
After a query cancel, the tail end of ExecQueryAndProcessResults took care to clear any not-yet-read PGresults; but it forgot about the one it has already read. There would only be such a result when handling a multi-command string made with "\;", so that you'd have to cancel an earlier command in such a string to reach the bug at all. Even then, there would only be leakage of a single PGresult per cancel, so it's not surprising nobody noticed this. But a leak is a leak. Noted while re-reviewing 90f5178, but this is independent of that: it dates to 7844c99. Back-patch to v15 where that came in.
1 parent 974374d commit a85e3ba

File tree

1 file changed

+2
-0
lines changed

1 file changed

+2
-0
lines changed

src/bin/psql/common.c

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1662,6 +1662,8 @@ ExecQueryAndProcessResults(const char *query,
16621662

16631663
if (cancel_pressed)
16641664
{
1665+
/* drop this next result, as well as any others not yet read */
1666+
ClearOrSaveResult(result);
16651667
ClearOrSaveAllResults();
16661668
break;
16671669
}

0 commit comments

Comments
 (0)
pFad - Phonifier reborn

Pfad - The Proxy pFad of © 2024 Garber Painting. All rights reserved.

Note: This service is not intended for secure transactions such as banking, social media, email, or purchasing. Use at your own risk. We assume no liability whatsoever for broken pages.


Alternative Proxies:

Alternative Proxy

pFad Proxy

pFad v3 Proxy

pFad v4 Proxy