mirror of
https://github.com/postgres/postgres.git
synced 2025-08-30 06:01:21 +03:00
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.
This commit is contained in:
@@ -604,6 +604,8 @@ lastcold(struct vars *v,
|
||||
|
||||
/*
|
||||
* newdfa - set up a fresh DFA
|
||||
*
|
||||
* Returns NULL (and sets v->err) on failure.
|
||||
*/
|
||||
static struct dfa *
|
||||
newdfa(struct vars *v,
|
||||
|
Reference in New Issue
Block a user