aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorAlvaro Herrera <alvherre@alvh.no-ip.org>2019-06-27 11:57:10 -0400
committerAlvaro Herrera <alvherre@alvh.no-ip.org>2019-06-27 11:57:10 -0400
commite4f2d4fe9269c3c9c33f5182d4c3c90f99587fb4 (patch)
tree82f668ac3ac3a121db7cbe8362612a03dd371077
parent9653ca2197e241ebeae127086ce1cc8b201a477e (diff)
downloadpostgresql-e4f2d4fe9269c3c9c33f5182d4c3c90f99587fb4.tar.gz
postgresql-e4f2d4fe9269c3c9c33f5182d4c3c90f99587fb4.zip
Fix use-after-free introduced in 55ed3defc966
Evidenced by failure under RELCACHE_FORCE_RELEASE (buildfarm member prion). Author: Amit Langote Discussion: https://postgr.es/m/CA+HiwqGV=k_Eh4jBiQw66ivvdG+EUkrEYeHTYL1SvDj_YOYV0g@mail.gmail.com
-rw-r--r--src/backend/commands/indexcmds.c7
1 files changed, 2 insertions, 5 deletions
diff --git a/src/backend/commands/indexcmds.c b/src/backend/commands/indexcmds.c
index 11370c65906..1faaaf625d9 100644
--- a/src/backend/commands/indexcmds.c
+++ b/src/backend/commands/indexcmds.c
@@ -896,13 +896,11 @@ DefineIndex(Oid relationId,
memcpy(part_oids, partdesc->oids, sizeof(Oid) * nparts);
- parentDesc = CreateTupleDescCopy(RelationGetDescr(rel));
+ parentDesc = RelationGetDescr(rel);
opfamOids = palloc(sizeof(Oid) * numberOfKeyAttributes);
for (i = 0; i < numberOfKeyAttributes; i++)
opfamOids[i] = get_opclass_family(classObjectId[i]);
- heap_close(rel, NoLock);
-
/*
* For each partition, scan all existing indexes; if one matches
* our index definition and is not already attached to some other
@@ -1100,13 +1098,12 @@ DefineIndex(Oid relationId,
heap_freetuple(newtup);
}
}
- else
- heap_close(rel, NoLock);
/*
* Indexes on partitioned tables are not themselves built, so we're
* done here.
*/
+ heap_close(rel, NoLock);
return address;
}