summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorKarl Williamson <khw@cpan.org>2018-10-19 11:49:01 -0600
committerKarl Williamson <khw@cpan.org>2018-10-20 00:09:56 -0600
commitdeeb899527fafbf46c2ae732d30fbaedd79d1b84 (patch)
tree76a701a2e3f6aa2a34bf458df28ef1e34d0a3284
parent4c8117d3827c12973c9516055b2dcef5138533b1 (diff)
downloadperl-deeb899527fafbf46c2ae732d30fbaedd79d1b84.tar.gz
regcomp.c: Avoid potential NULL ptr dereference
This commit cause the passed in variable to be non-NULL before dereferencing it, as defensive coding practice. A future commit causes this to matter.
-rw-r--r--regcomp.c7
1 files changed, 7 insertions, 0 deletions
diff --git a/regcomp.c b/regcomp.c
index c6c3a5e265..8f338ae926 100644
--- a/regcomp.c
+++ b/regcomp.c
@@ -20277,6 +20277,9 @@ Perl_pregfree2(pTHX_ REGEXP *rx)
PERL_ARGS_ASSERT_PREGFREE2;
+ if (! r)
+ return;
+
if (r->mother_re) {
ReREFCNT_dec(r->mother_re);
} else {
@@ -20422,6 +20425,10 @@ Perl_regfree_internal(pTHX_ REGEXP * const rx)
PERL_ARGS_ASSERT_REGFREE_INTERNAL;
+ if (! ri) {
+ return;
+ }
+
DEBUG_COMPILE_r({
if (!PL_colorset)
reginitcolors();