From: | Tom Lane <tgl(at)sss(dot)pgh(dot)pa(dot)us> |
---|---|
To: | Andrew Dunstan <andrew(at)dunslane(dot)net> |
Cc: | Amul Sul <sulamul(at)gmail(dot)com>, Andres Freund <andres(at)anarazel(dot)de>, Alexander Korotkov <aekorotkov(at)gmail(dot)com>, Robert Haas <robertmhaas(at)gmail(dot)com>, "David G(dot) Johnston" <david(dot)g(dot)johnston(at)gmail(dot)com>, Corey Huinker <corey(dot)huinker(at)gmail(dot)com>, Alvaro Herrera <alvherre(at)alvh(dot)no-ip(dot)org>, Joe Conway <mail(at)joeconway(dot)com>, Nikita Glukhov <n(dot)gluhov(at)postgrespro(dot)ru>, PostgreSQL Hackers <pgsql-hackers(at)lists(dot)postgresql(dot)org> |
Subject: | Re: Error-safe user functions |
Date: | 2022-12-24 15:42:35 |
Message-ID: | 2911749.1671896555@sss.pgh.pa.us |
Views: | Raw Message | Whole Thread | Download mbox | Resend email |
Thread: | |
Lists: | pgsql-hackers |
Andrew Dunstan <andrew(at)dunslane(dot)net> writes:
> As I was giving this a final polish I noticed this in jspConvertRegexFlags:
> /*
> * We'll never need sub-match details at execution. While
> * RE_compile_and_execute would set this flag anyway, force it on here to
> * ensure that the regex cache entries created by makeItemLikeRegex are
> * useful.
> */
> cflags |= REG_NOSUB;
> Clearly the comment would no longer be true. I guess I should just
> remove this?
Yeah, we can just drop that I guess. I'm slightly worried that we might
need it again after some future refactoring; but it's not really worth
devising a re-worded comment to justify keeping it.
Also, I realized that I failed in my reviewerly duty by not noticing
that you'd forgotten to pg_regfree the regex after successful
compilation. Running something like this exposes the memory leak
very quickly:
select pg_input_is_valid('$ ? (@ like_regex "pattern" flag "smixq")', 'jsonpath')
from generate_series(1,10000000);
The attached delta patch takes care of it. (Per comment at pg_regcomp,
we don't need this after a failure return.)
regards, tom lane
Attachment | Content-Type | Size |
---|---|---|
dont-leak-compiled-regex.patch | text/x-diff | 466 bytes |
From | Date | Subject | |
---|---|---|---|
Next Message | Tom Lane | 2022-12-24 15:48:11 | Re: Error-safe user functions |
Previous Message | Nikita Malakhov | 2022-12-24 15:10:47 | Re: ARRNELEMS Out-of-bounds possible errors |