aboutsummaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorAlvaro Herrera <alvherre@alvh.no-ip.org>2017-03-24 15:43:03 -0300
committerAlvaro Herrera <alvherre@alvh.no-ip.org>2017-03-24 15:43:15 -0300
commit8082bea2b06eb6bcd6cce4cc7801094c17045b4f (patch)
tree808a471cac8539d508157761e903346a0ae54b14 /src
parent3428ef79115927c92c6e2ab6f261f5de5dc4e914 (diff)
downloadpostgresql-8082bea2b06eb6bcd6cce4cc7801094c17045b4f.tar.gz
postgresql-8082bea2b06eb6bcd6cce4cc7801094c17045b4f.zip
Fix use-after-free bug
Detected by buildfarm member prion
Diffstat (limited to 'src')
-rw-r--r--src/backend/commands/statscmds.c11
1 files changed, 6 insertions, 5 deletions
diff --git a/src/backend/commands/statscmds.c b/src/backend/commands/statscmds.c
index 416309106a7..07503299610 100644
--- a/src/backend/commands/statscmds.c
+++ b/src/backend/commands/statscmds.c
@@ -230,6 +230,12 @@ CreateStatistics(CreateStatsStmt *stmt)
statoid = HeapTupleGetOid(htup);
heap_freetuple(htup);
heap_close(statrel, RowExclusiveLock);
+
+ /*
+ * Invalidate relcache so that others see the new statistics.
+ */
+ CacheInvalidateRelcache(rel);
+
relation_close(rel, NoLock);
/*
@@ -250,11 +256,6 @@ CreateStatistics(CreateStatsStmt *stmt)
ObjectAddressSet(address, StatisticExtRelationId, statoid);
- /*
- * Invalidate relcache so that others see the new statistics.
- */
- CacheInvalidateRelcache(rel);
-
return address;
}