Fix use-after-free in ri_LoadConstraintInfo

conindid was read from conForm after ReleaseSysCache(tup).  Move
the read to before the release.

Introduced by commit 2da86c1ef9.

Per buildfarm member prion.

Discussion: https://postgr.es/m/CA+HiwqGGYjN6F2oL7yAk=hvSs-sj3TPqZ9JC9iyLkCqJadECrw@mail.gmail.com
This commit is contained in:
Amit Langote 2026-03-31 17:04:44 +09:00
parent 097ab69d17
commit 68a8601ee9

View file

@ -2396,6 +2396,11 @@ ri_LoadConstraintInfo(Oid constraintOid)
&riinfo->period_intersect_oper);
}
/* Metadata used by fast path. */
riinfo->conindid = conForm->conindid;
riinfo->pk_is_partitioned =
(get_rel_relkind(riinfo->pk_relid) == RELKIND_PARTITIONED_TABLE);
ReleaseSysCache(tup);
/*
@ -2406,10 +2411,6 @@ ri_LoadConstraintInfo(Oid constraintOid)
riinfo->valid = true;
riinfo->conindid = conForm->conindid;
riinfo->pk_is_partitioned =
(get_rel_relkind(riinfo->pk_relid) == RELKIND_PARTITIONED_TABLE);
riinfo->fpmeta = NULL;
return riinfo;