bug-gnulib
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[PATCH 2/2] regex: fix minor over-allocation


From: Paul Eggert
Subject: [PATCH 2/2] regex: fix minor over-allocation
Date: Fri, 11 Mar 2022 13:35:40 -0800

* lib/regexec.c (push_fail_stack): Fix off-by-one error that
over-allocated the stack.
---
 ChangeLog     | 4 ++++
 lib/regexec.c | 2 +-
 2 files changed, 5 insertions(+), 1 deletion(-)

diff --git a/ChangeLog b/ChangeLog
index 50f60c6372..7a6ade78c3 100644
--- 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
diff --git a/lib/regexec.c b/lib/regexec.c
index 0691e91e1e..521cb02841 100644
--- a/lib/regexec.c
+++ b/lib/regexec.c
@@ -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,
-- 
2.35.1




reply via email to

[Prev in Thread] Current Thread [Next in Thread]