Skip to content

Commit 393e828

Browse files
committed
Avoid potential relcache leak in objectaddress.c.
Nobody using the missing_ok flag yet, but let's speculate that this will be a better interface for future callers. KaiGai Kohei, with some adjustments by me.
1 parent ad30d36 commit 393e828

File tree

1 file changed

+10
-1
lines changed

1 file changed

+10
-1
lines changed

src/backend/catalog/objectaddress.c

Lines changed: 10 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -639,7 +639,8 @@ get_object_address_relobject(ObjectType objtype, List *objname,
639639
* Caller is expecting to get back the relation, even though we
640640
* didn't end up using it to find the rule.
641641
*/
642-
relation = heap_open(reloid, AccessShareLock);
642+
if (OidIsValid(address.objectId))
643+
relation = heap_open(reloid, AccessShareLock);
643644
}
644645
else
645646
{
@@ -677,6 +678,14 @@ get_object_address_relobject(ObjectType objtype, List *objname,
677678
address.objectId = InvalidOid;
678679
address.objectSubId = 0;
679680
}
681+
682+
/* Avoid relcache leak when object not found. */
683+
if (!OidIsValid(address.objectId))
684+
{
685+
heap_close(relation, AccessShareLock);
686+
relation = NULL; /* department of accident prevention */
687+
return address;
688+
}
680689
}
681690

682691
/* Done. */

0 commit comments

Comments
 (0)
pFad - Phonifier reborn

Pfad - The Proxy pFad of © 2024 Garber Painting. All rights reserved.

Note: This service is not intended for secure transactions such as banking, social media, email, or purchasing. Use at your own risk. We assume no liability whatsoever for broken pages.


Alternative Proxies:

Alternative Proxy

pFad Proxy

pFad v3 Proxy

pFad v4 Proxy