summary refs log tree commit diff
diff options
context:
space:
mode:
-rw-r--r--ChangeLog7
-rw-r--r--posix/regcomp.c5
-rw-r--r--posix/regexec.c17
3 files changed, 14 insertions, 15 deletions
diff --git a/ChangeLog b/ChangeLog
index 011f910a9f..bfa5d7aea1 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,11 +1,12 @@
 2003-12-28  Ulrich Drepper  <drepper@redhat.com>
 
-	* posix/regexec.c (re_copy_regs): Allocate start and end array in
-	one block.
+	* posix/regcomp.c (mark_opt_subexp_iter): Declare IDX as int.
+
+	* posix/regexec.c (re_copy_regs): Fix testing for failed allocation.
 	(push_fail_stack): Add missing check for failed memory allocation.
 
 	* libio/libio.h: Use __builtin_expect in _IO_getc_unlocked,
-	_IO_peekc_unlocked, _IO_ptc_unlocked, _IO_getwc_unlocked, and
+	_IO_peekc_unlocked, _IO_putc_unlocked, _IO_getwc_unlocked, and
 	_IO_putwc_unlocked.
 
 2003-12-28  Andreas Jaeger  <aj@suse.de>
diff --git a/posix/regcomp.c b/posix/regcomp.c
index 38b1b9c604..826486463e 100644
--- a/posix/regcomp.c
+++ b/posix/regcomp.c
@@ -614,7 +614,7 @@ free_dfa_content (re_dfa_t *dfa)
   re_free (dfa->word_char);
 #ifdef RE_ENABLE_I18N
   re_free (dfa->sb_char);
-#endif  
+#endif
 #ifdef DEBUG
   re_free (dfa->re_str);
 #endif
@@ -2479,7 +2479,7 @@ parse_dup_op (elem, regexp, dfa, token, syntax, err)
           mark_opt_subexp (elem, dfa);
           tree = elem = re_dfa_add_tree_node (dfa, elem, NULL, &dup_token);
 	}
-      
+
       if (BE (elem == NULL || tree == NULL, 0))
         goto parse_dup_op_espace;
 
@@ -3731,6 +3731,7 @@ static void
 mark_opt_subexp_iter (src, dfa, idx)
      const bin_tree_t *src;
      re_dfa_t *dfa;
+     int idx;
 {
   int node_idx;
 
diff --git a/posix/regexec.c b/posix/regexec.c
index 8f1f8c6b1f..9d1af80c0d 100644
--- a/posix/regexec.c
+++ b/posix/regexec.c
@@ -455,10 +455,10 @@ re_copy_regs (regs, pmatch, nregs, regs_allocated)
   if (regs_allocated == REGS_UNALLOCATED)
     { /* No.  So allocate them with malloc.  We allocate the arrays
 	 for the start and end in one block.  */
-      regs->start = re_malloc (regoff_t, 2 * need_regs);
-      if (BE (regs->start == NULL, 0))
+      regs->start = re_malloc (regoff_t, need_regs);
+      regs->end = re_malloc (regoff_t, need_regs);
+      if (BE (regs->start == NULL, 0) || BE (regs->end == NULL, 0))
 	return REGS_UNALLOCATED;
-      regs->end = regs->start + need_regs;
       regs->num_regs = need_regs;
     }
   else if (regs_allocated == REGS_REALLOCATE)
@@ -467,13 +467,10 @@ re_copy_regs (regs, pmatch, nregs, regs_allocated)
 	 leave it alone.  */
       if (BE (need_regs > regs->num_regs, 0))
 	{
-	  regs->start = re_realloc (regs->start, regoff_t, 2 * need_regs);
-	  if (BE (regs->start == NULL, 0))
-	    {
-	      regs->end = NULL;
-	      return REGS_UNALLOCATED;
-	    }
-	  regs->end = regs->start + need_regs;
+	  regs->start = re_realloc (regs->start, regoff_t, need_regs);
+	  regs->end = re_realloc (regs->end, regoff_t, need_regs);
+	  if (BE (regs->start == NULL, 0) || BE (regs->end == NULL, 0))
+	    return REGS_UNALLOCATED;
 	  regs->num_regs = need_regs;
 	}
     }