Location via proxy:   [ UP ]  
[Report a bug]   [Manage cookies]                
Remove NULL dereference from RenameRelationInternal().
authorNoah Misch <noah@leadboat.com>
Sun, 29 Sep 2024 22:54:25 +0000 (15:54 -0700)
committerNoah Misch <noah@leadboat.com>
Sun, 29 Sep 2024 22:54:29 +0000 (15:54 -0700)
Defect in last week's commit aac2c9b4fde889d13f859c233c2523345e72d32b,
per Coverity.  Reaching this would need catalog corruption.  Back-patch
to v12, like that commit.

src/backend/commands/tablecmds.c

index 53286b3f3f97e07bacb0f0f8557f9b433d8902a0..41017b38d411e41d8c3a2d4f9f644915de9fb72c 100644 (file)
@@ -3682,9 +3682,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)