From: Tom Lane Date: Wed, 6 Jan 2010 22:27:09 +0000 (+0000) Subject: Access hash entry before freeing it, not after. X-Git-Tag: REL9_0_ALPHA4~312 X-Git-Url: https://granicus.if.org/sourcecode?a=commitdiff_plain;h=64b9c850e9c4963b2f21c5961fa7765f1ab59506;p=postgresql Access hash entry before freeing it, not after. --- diff --git a/src/backend/utils/cache/spccache.c b/src/backend/utils/cache/spccache.c index 00629c09f0..7de65b31b7 100644 --- a/src/backend/utils/cache/spccache.c +++ b/src/backend/utils/cache/spccache.c @@ -12,7 +12,7 @@ * Portions Copyright (c) 1994, Regents of the University of California * * IDENTIFICATION - * $PostgreSQL: pgsql/src/backend/utils/cache/spccache.c,v 1.1 2010/01/05 21:53:59 rhaas Exp $ + * $PostgreSQL: pgsql/src/backend/utils/cache/spccache.c,v 1.2 2010/01/06 22:27:09 tgl Exp $ * *------------------------------------------------------------------------- */ @@ -54,11 +54,13 @@ InvalidateTableSpaceCacheCallback(Datum arg, int cacheid, ItemPointer tuplePtr) hash_seq_init(&status, TableSpaceCacheHash); while ((spc = (TableSpace *) hash_seq_search(&status)) != NULL) { - if (hash_search(TableSpaceCacheHash, (void *) &spc->oid, HASH_REMOVE, - NULL) == NULL) - elog(ERROR, "hash table corrupted"); if (spc->opts) pfree(spc->opts); + if (hash_search(TableSpaceCacheHash, + (void *) &spc->oid, + HASH_REMOVE, + NULL) == NULL) + elog(ERROR, "hash table corrupted"); } }