diff options
Diffstat (limited to 'src/backend/access/spgist/spgscan.c')
-rw-r--r-- | src/backend/access/spgist/spgscan.c | 10 |
1 files changed, 7 insertions, 3 deletions
diff --git a/src/backend/access/spgist/spgscan.c b/src/backend/access/spgist/spgscan.c index c7280808122..5260d5017d1 100644 --- a/src/backend/access/spgist/spgscan.c +++ b/src/backend/access/spgist/spgscan.c @@ -74,6 +74,13 @@ resetSpGistScanOpaque(SpGistScanOpaque so) freeScanStack(so); + /* + * clear traversal context before proceeding to the next scan; this must + * not happen before the freeScanStack above, else we get double-free + * crashes. + */ + MemoryContextReset(so->traversalCxt); + if (so->searchNulls) { /* Stack a work item to scan the null index entries */ @@ -212,9 +219,6 @@ spgrescan(IndexScanDesc scan, ScanKey scankey, int nscankeys, { SpGistScanOpaque so = (SpGistScanOpaque) scan->opaque; - /* clear traversal context before proceeding to the next scan */ - MemoryContextReset(so->traversalCxt); - /* copy scankeys into local storage */ if (scankey && scan->numberOfKeys > 0) { |