Skip to content

Commit

Permalink
regcomp.c: Avoid potential NULL ptr dereference
Browse files Browse the repository at this point in the history
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.
  • Loading branch information
khwilliamson committed Oct 20, 2018
1 parent 4c8117d commit deeb899
Showing 1 changed file with 7 additions and 0 deletions.
7 changes: 7 additions & 0 deletions regcomp.c
Original file line number Diff line number Diff line change
Expand Up @@ -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 {
Expand Down Expand Up @@ -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();
Expand Down

0 comments on commit deeb899

Please sign in to comment.