Skip to content

Commit 64b9c85

Browse files
committed
Access hash entry before freeing it, not after.
1 parent 87ac6e7 commit 64b9c85

File tree

1 file changed

+6
-4
lines changed

1 file changed

+6
-4
lines changed

src/backend/utils/cache/spccache.c

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@
1212
* Portions Copyright (c) 1994, Regents of the University of California
1313
*
1414
* IDENTIFICATION
15-
* $PostgreSQL: pgsql/src/backend/utils/cache/spccache.c,v 1.1 2010/01/05 21:53:59 rhaas Exp $
15+
* $PostgreSQL: pgsql/src/backend/utils/cache/spccache.c,v 1.2 2010/01/06 22:27:09 tgl Exp $
1616
*
1717
*-------------------------------------------------------------------------
1818
*/
@@ -54,11 +54,13 @@ InvalidateTableSpaceCacheCallback(Datum arg, int cacheid, ItemPointer tuplePtr)
5454
hash_seq_init(&status, TableSpaceCacheHash);
5555
while ((spc = (TableSpace *) hash_seq_search(&status)) != NULL)
5656
{
57-
if (hash_search(TableSpaceCacheHash, (void *) &spc->oid, HASH_REMOVE,
58-
NULL) == NULL)
59-
elog(ERROR, "hash table corrupted");
6057
if (spc->opts)
6158
pfree(spc->opts);
59+
if (hash_search(TableSpaceCacheHash,
60+
(void *) &spc->oid,
61+
HASH_REMOVE,
62+
NULL) == NULL)
63+
elog(ERROR, "hash table corrupted");
6264
}
6365
}
6466

0 commit comments

Comments
 (0)