Re: [PATCH][BUG FIX] Unsafe access pointers.

From: Daniel Gustafsson <daniel(at)yesql(dot)se>
To: Ranier Vilela <ranier_gyn(at)hotmail(dot)com>
Cc: "pgsql-hackers(at)lists(dot)postgresql(dot)org" <pgsql-hackers(at)lists(dot)postgresql(dot)org>
Subject: Re: [PATCH][BUG FIX] Unsafe access pointers.
Date: 2019-11-15 11:58:36
Message-ID: FCE1BDEF-8B51-4AC2-9FE7-B885B3CFA321@yesql.se
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-hackers

> On 15 Nov 2019, at 12:25, Ranier Vilela <ranier_gyn(at)hotmail(dot)com> wrote:

> It's probably not happening, but it can happen, I think.

I don't think it can, given how elog() works.

> - if (!HeapTupleIsValid(classtup))
> + if (!HeapTupleIsValid(classtup)) {
> elog(ERROR, "cache lookup failed for operator class %u", opclassoid);
> + return false;

elog or ereport with a severity of ERROR or higher will never return.

> - if (!HeapTupleIsValid(familytup))
> + if (!HeapTupleIsValid(familytup)) {
> elog(ERROR, "cache lookup failed for operator family %u", opfamilyoid);
> + ReleaseSysCache(classtup);
> + return false;
> + }

Not only will elog(ERROR ..) not return to run this, the errorhandling
machinery will automatically release resources and clean up.

cheers ./daniel

In response to

Responses

Browse pgsql-hackers by date

  From Date Subject
Next Message Fabien COELHO 2019-11-15 12:01:21 Re: segfault in geqo on experimental gcc animal
Previous Message Ranier Vilela 2019-11-15 11:25:07 [PATCH][BUG FIX] Unsafe access pointers.