forked frompostgres/postgres
- Notifications
You must be signed in to change notification settings - Fork6
Commitab4ff28
committed
Fix memory leak in repeated GIN index searches.
Commitd88976c removed this code from ginFreeScanKeys():-if (entry->list)-pfree(entry->list);evidently in the belief that that ItemPointer array is allocated in thekeyCtx and so would be reclaimed by the following MemoryContextReset.Unfortunately, it isn't and it won't. It'd likely be a good idea forthat to become so, but as a simple and back-patchable fix in themeantime, restore this code to ginFreeScanKeys().Also, add a similar pfree to where startScanEntry() is about to zero outentry->list. I am not sure if there are any code paths where thischange prevents a leak today, but it seems like cheap future-proofing.In passing, make the initial allocation of so->entries[] use pallocnot palloc0. The code doesn't depend on unused entries being zero;if it did, the array-enlargement code in ginFillScanEntry() would bewrong. So using palloc0 initially can only serve to confuse readersabout what the invariant is.Per report from Felipe de Jesús Molina Bravo, via Jaime Casanova in<CAJGNTeMR1ndMU2Thpr8GPDUfiHTV7idELJRFusA5UXUGY1y-eA@mail.gmail.com>1 parent96adb14 commitab4ff28
2 files changed
+5
-1
lines changedLines changed: 2 additions & 0 deletions
Original file line number | Diff line number | Diff line change | |
---|---|---|---|
| |||
302 | 302 |
| |
303 | 303 |
| |
304 | 304 |
| |
| 305 | + | |
| 306 | + | |
305 | 307 |
| |
306 | 308 |
| |
307 | 309 |
| |
|
Lines changed: 3 additions & 1 deletion
Original file line number | Diff line number | Diff line change | |
---|---|---|---|
| |||
246 | 246 |
| |
247 | 247 |
| |
248 | 248 |
| |
| 249 | + | |
| 250 | + | |
249 | 251 |
| |
250 | 252 |
| |
251 | 253 |
| |
| |||
285 | 287 |
| |
286 | 288 |
| |
287 | 289 |
| |
288 |
| - | |
| 290 | + | |
289 | 291 |
| |
290 | 292 |
| |
291 | 293 |
| |
|
0 commit comments
Comments
(0)