From 438975bbaa25b7de74993e7928c45cf5779442b8 Mon Sep 17 00:00:00 2001 From: Paul Eggert Date: Wed, 26 Aug 2020 00:07:08 -0700 Subject: [PATCH] regex-emacs omit POS runtime check * src/regex-emacs.c (re_match_2_internal): Replace unnecessary runtime check of POS with some eassumes. --- src/regex-emacs.c | 12 ++++-------- 1 file changed, 4 insertions(+), 8 deletions(-) diff --git a/src/regex-emacs.c b/src/regex-emacs.c index c44cce9f787..954a193371a 100644 --- a/src/regex-emacs.c +++ b/src/regex-emacs.c @@ -3864,6 +3864,10 @@ re_match_2_internal (struct re_pattern_buffer *bufp, re_char *string2, ptrdiff_t size2, ptrdiff_t pos, struct re_registers *regs, ptrdiff_t stop) { + eassume (0 <= size1); + eassume (0 <= size2); + eassume (0 <= pos && pos <= stop && stop <= size1 + size2); + /* General temporaries. */ int mcnt; @@ -3979,14 +3983,6 @@ re_match_2_internal (struct re_pattern_buffer *bufp, best_regend = best_regstart + num_regs; } - /* The starting position is bogus. */ - if (pos < 0 || pos > size1 + size2) - { - unbind_to (count, Qnil); - SAFE_FREE (); - return -1; - } - /* Initialize subexpression text positions to -1 to mark ones that no start_memory/stop_memory has been seen for. */ for (ptrdiff_t reg = 1; reg < num_regs; reg++) -- 2.39.2