regcomp.c: Use an equivalent 'if' condition
authorKarl Williamson <khw@cpan.org>
Sun, 14 Oct 2018 20:30:50 +0000 (14:30 -0600)
committerKarl Williamson <khw@cpan.org>
Sat, 20 Oct 2018 06:09:55 +0000 (00:09 -0600)
By inspection of the code, I see that this 'if' won't get executed
unless the variable is non-null.  The function whose return sets it
will raise an error if it would otherwise return NULL unexpectedly.

regcomp.c

index 528b690..f4387ef 100644 (file)
--- a/regcomp.c
+++ b/regcomp.c
@@ -11538,10 +11538,10 @@ S_reg(pTHX_ RExC_state_t *pRExC_state, I32 paren, I32 *flagp, U32 depth)
                             (ch == '>' ? '<' : ch));
                     }
                     RExC_parse++;
-                   if (!SIZE_ONLY) {
+                    if (sv_dat) {
                         num = add_data( pRExC_state, STR_WITH_LEN("S"));
                         RExC_rxi->data->data[num]=(void*)sv_dat;
-                        SvREFCNT_inc_simple_void(sv_dat);
+                        SvREFCNT_inc_simple_void_NN(sv_dat);
                     }
                     ret = reganode(pRExC_state, NGROUPP, num);
                     goto insert_if_check_paren;