From bf1587490b4be51c5a8b3393bf0acbc2470f196a Mon Sep 17 00:00:00 2001 From: "Philip.Hazel" Date: Fri, 20 May 2016 10:47:42 +0000 Subject: [PATCH] Minor code refactor to avoid compiler warning. --- ChangeLog | 4 ++++ src/pcre2_compile.c | 20 +++++++++----------- 2 files changed, 13 insertions(+), 11 deletions(-) diff --git a/ChangeLog b/ChangeLog index 754d0e5..87ceb27 100644 --- a/ChangeLog +++ b/ChangeLog @@ -108,6 +108,10 @@ been re-factored and no longer includes pcre2_internal.h. 25. A racing condition is fixed in JIT reported by Mozilla. +26. Minor code refactor to avoid "array subscript is below array bounds" +compiler warning. + + Version 10.21 12-January-2016 ----------------------------- diff --git a/src/pcre2_compile.c b/src/pcre2_compile.c index baaff3d..779c1a2 100644 --- a/src/pcre2_compile.c +++ b/src/pcre2_compile.c @@ -3962,6 +3962,10 @@ for (;; ptr++) uint32_t subreqcu, subfirstcu; int32_t subreqcuflags, subfirstcuflags; /* Must be signed */ PCRE2_UCHAR mcbuffer[8]; + + /* Come here to restart the loop. */ + + REDO_LOOP: /* Get next character in the pattern */ @@ -4103,11 +4107,7 @@ for (;; ptr++) /* If we skipped any characters, restart the loop. Otherwise, we didn't see a comment. */ - if (ptr > wscptr) - { - ptr--; - continue; - } + if (ptr > wscptr) goto REDO_LOOP; } /* Skip over (?# comments. */ @@ -4247,17 +4247,15 @@ for (;; ptr++) if (PRIV(strncmp_c8)(ptr+1, STRING_WEIRD_STARTWORD, 6) == 0) { cb->nestptr[0] = ptr + 7; - ptr = sub_start_of_word; /* Do not combine these statements; clang's */ - ptr--; /* sanitizer moans about a negative index. */ - continue; + ptr = sub_start_of_word; + goto REDO_LOOP; } if (PRIV(strncmp_c8)(ptr+1, STRING_WEIRD_ENDWORD, 6) == 0) { cb->nestptr[0] = ptr + 7; - ptr = sub_end_of_word; /* Do not combine these statements; clang's */ - ptr--; /* sanitizer moans about a negative index. */ - continue; + ptr = sub_end_of_word; + goto REDO_LOOP; } /* Handle a real character class. */