Commit 5f79580
committed
Fix memory lifetime issues of replication slot stats.
When accessing replication slot stats, introduced in 9868167,
pgstat_read_statsfiles() reads the data into newly allocated
memory. Unfortunately the current memory context at that point is the
callers, leading to leaks and use-after-free dangers.
The fix is trivial, explicitly use pgStatLocalContext. There's some
potential for further improvements, but that's outside of the scope of
this bugfix.
No backpatch necessary, feature is only in HEAD.
Author: Andres Freund <andres@anarazel.de>
Discussion: https://postgr.es/m/20210317230447.c7uc4g3vbs4wi32i@alap3.anarazel.de1 parent 7094564 commit 5f79580
3 files changed
+28
-1
lines changed| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
101 | 101 | | |
102 | 102 | | |
103 | 103 | | |
| 104 | + | |
| 105 | + | |
| 106 | + | |
| 107 | + | |
| 108 | + | |
| 109 | + | |
| 110 | + | |
| 111 | + | |
| 112 | + | |
| 113 | + | |
| 114 | + | |
| 115 | + | |
| 116 | + | |
| 117 | + | |
| 118 | + | |
| 119 | + | |
104 | 120 | | |
105 | 121 | | |
106 | 122 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
59 | 59 | | |
60 | 60 | | |
61 | 61 | | |
| 62 | + | |
| 63 | + | |
| 64 | + | |
| 65 | + | |
| 66 | + | |
| 67 | + | |
| 68 | + | |
62 | 69 | | |
63 | 70 | | |
64 | 71 | | |
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
5568 | 5568 | | |
5569 | 5569 | | |
5570 | 5570 | | |
5571 | | - | |
| 5571 | + | |
| 5572 | + | |
| 5573 | + | |
5572 | 5574 | | |
5573 | 5575 | | |
5574 | 5576 | | |
| |||
6323 | 6325 | | |
6324 | 6326 | | |
6325 | 6327 | | |
| 6328 | + | |
| 6329 | + | |
6326 | 6330 | | |
6327 | 6331 | | |
6328 | 6332 | | |
| |||
0 commit comments