]> Savannah Git Hosting - gnulib.git/commitdiff
regex: fix minor over-allocation
authorPaul Eggert <eggert@cs.ucla.edu>
Fri, 11 Mar 2022 21:34:07 +0000 (13:34 -0800)
committerPaul Eggert <eggert@cs.ucla.edu>
Fri, 11 Mar 2022 21:34:42 +0000 (13:34 -0800)
* lib/regexec.c (push_fail_stack): Fix off-by-one error that
over-allocated the stack.

ChangeLog
lib/regexec.c

index 50f60c6372051541f138ab95a6c497d972e6d53f..7a6ade78c384b8691bc4caf6a4edb3691fe17b4a 100644 (file)
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,5 +1,9 @@
 2022-03-11  Paul Eggert  <eggert@cs.ucla.edu>
 
+       regex: fix minor over-allocation
+       * lib/regexec.c (push_fail_stack): Fix off-by-one error that
+       over-allocated the stack.
+
        regex: fix free_fail_stack undefined behavior
        * lib/regexec.c (push_fail_stack): Don’t increment number of
        re_fail_stack_t entries until after successful allocation.  This
index 0691e91e1ee7d2790bc6b822eb752a4bc41aa454..521cb0284152261bcbf062bbbec38778a5181fda 100644 (file)
@@ -1309,7 +1309,7 @@ push_fail_stack (struct re_fail_stack_t *fs, Idx str_idx, Idx dest_node,
 {
   reg_errcode_t err;
   Idx num = fs->num;
-  if (num + 1 == fs->alloc)
+  if (num == fs->alloc)
     {
       struct re_fail_stack_ent_t *new_array;
       new_array = re_realloc (fs->stack, struct re_fail_stack_ent_t,