From: Noah Misch Date: Sun, 29 Sep 2024 22:54:25 +0000 (-0700) Subject: Remove NULL dereference from RenameRelationInternal(). X-Git-Tag: REL_14_14~60 X-Git-Url: http://git.postgresql.org/gitweb/?a=commitdiff_plain;h=b9ee1339bfbe078ee04468dfce2820248061155b;p=postgresql.git Remove NULL dereference from RenameRelationInternal(). Defect in last week's commit aac2c9b4fde889d13f859c233c2523345e72d32b, per Coverity. Reaching this would need catalog corruption. Back-patch to v12, like that commit. --- diff --git a/src/backend/commands/tablecmds.c b/src/backend/commands/tablecmds.c index 2c68d89f379..38cc7f6b854 100644 --- a/src/backend/commands/tablecmds.c +++ b/src/backend/commands/tablecmds.c @@ -3861,9 +3861,9 @@ RenameRelationInternal(Oid myrelid, const char *newrelname, bool is_internal, bo relrelation = table_open(RelationRelationId, RowExclusiveLock); reltup = SearchSysCacheLockedCopy1(RELOID, ObjectIdGetDatum(myrelid)); - otid = reltup->t_self; if (!HeapTupleIsValid(reltup)) /* shouldn't happen */ elog(ERROR, "cache lookup failed for relation %u", myrelid); + otid = reltup->t_self; relform = (Form_pg_class) GETSTRUCT(reltup); if (get_relname_relid(newrelname, namespaceId) != InvalidOid)