pg.ddx.io  pgsql-committers@postgresql.org mailing list archive  
help / color / mirror / Atom feed
From: Tom Lane <tgl@sss.pgh.pa.us>
To: pgsql-committers@lists.postgresql.org
Subject: pgsql: Further tweak memory management for regex DFAs.
Date: Mon, 08 Mar 2021 21:32:52 +0000
Message-ID: <E1lJNUi-0003Tn-Fz@gemulon.postgresql.org> (raw)

Further tweak memory management for regex DFAs.

Coverity is still unhappy after commit 190c79884, and after looking
closer I think it might be onto something.  The callers of newdfa()
typically drop out if v->err has been set nonzero, which newdfa()
is faithfully doing if it fails.  However, what if v->err was already
nonzero before we entered newdfa()?  Then newdfa() could succeed and
the caller would promptly leak its result.

I don't think this scenario can actually happen, but the predicate
"v->err is always zero when newdfa() is called" seems difficult to be
entirely sure of; there's a good deal of code that potentially could
get that wrong.

It seems better to adjust the callers to directly check for a null
result instead of relying on ISERR() tests.  This is slightly cheaper
than the previous coding anyway.

Lacking evidence that there's any real bug, no back-patch.

Branch
------
master

Details
-------
https://git.postgresql.org/pg/commitdiff/6c20bdb2a279086777a3595ab00bcf14671fc5a1

Modified Files
--------------
src/backend/regex/rege_dfa.c |  2 ++
src/backend/regex/regexec.c  | 18 ++++++++----------
2 files changed, 10 insertions(+), 10 deletions(-)



Message-ID: <E1lJNUi-0003Tn-Fz@gemulon.postgresql.org>
Permalink:  ../E1lJNUi-0003Tn-Fz@gemulon.postgresql.org/
Also on:    postgresql.org/message-id/E1lJNUi-0003Tn-Fz@gemulon.postgresql.org

 · 

reply

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Reply to all the recipients from your mail client; the link fills in
  the headers below: reply via email
  Some clients, webmail especially, drop In-Reply-To and References from
  a link, and the reply then starts a new thread: use the mbox below.

  To: pgsql-committers@postgresql.org
  Cc: tgl@sss.pgh.pa.us
  Subject: Re: pgsql: Further tweak memory management for regex DFAs.
  In-Reply-To: <E1lJNUi-0003Tn-Fz@gemulon.postgresql.org>
  References: <E1lJNUi-0003Tn-Fz@gemulon.postgresql.org>

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

This inbox is served by DDX for PostgreSQL; see mirroring instructions
for how to clone and mirror all data and code used for this inbox