Coverity insists that if we deference a pointer without checking, and
authorNicholas Clark <nick@ccl4.org>
Tue, 18 Apr 2006 10:54:15 +0000 (10:54 +0000)
committerNicholas Clark <nick@ccl4.org>
Tue, 18 Apr 2006 10:54:15 +0000 (10:54 +0000)
subsequently check that same pointer before deferencing it, something
in our code or our logic is bogus. So assert() that it's safe the
first time and remove the second check.

p4raw-id: //depot/perl@27882

regcomp.c

index a820e5a..d2e99a1 100644 (file)
--- a/regcomp.c
+++ b/regcomp.c
@@ -2030,15 +2030,17 @@ S_study_chunk(pTHX_ RExC_state_t *pRExC_state, regnode **scanp, I32 *deltap,
            UV uc = *((U8*)STRING(scan));
 
            /* Search for fixed substrings supports EXACT only. */
-           if (flags & SCF_DO_SUBSTR)
+           if (flags & SCF_DO_SUBSTR) {
+               assert(data);
                scan_commit(pRExC_state, data);
+           }
            if (UTF) {
                const U8 * const s = (U8 *)STRING(scan);
                l = utf8_length(s, s + l);
                uc = utf8_to_uvchr(s, NULL);
            }
            min += l;
-           if (data && (flags & SCF_DO_SUBSTR))
+           if (flags & SCF_DO_SUBSTR)
                data->pos_min += l;
            if (flags & SCF_DO_STCLASS_AND) {
                /* Check whether it is compatible with what we know already! */