[PATCH] re_compile_pattern error handling
Jakub Jelinek
jakub@redhat.com
Thu Jan 16 17:17:00 GMT 2003
Hi!
I'm not sure if we are required to do this or not, but
if re_compile_pattern fails, it leaves the pattern buffer with cleared
buffer argument, but non-zero allocated, so if the application doesn't clear
allocated itself before calling re_compile_pattern on that pattern buffer
again, it segfaults.
2003-01-16 Jakub Jelinek <jakub@redhat.com>
* posix/regcomp.c (re_compile_internal): If clearing buffer, clear
allocated too. Reported by Al Viro <aviro@redhat.com>.
--- libc/posix/regcomp.c.jj 2002-12-20 13:42:50.000000000 +0100
+++ libc/posix/regcomp.c 2003-01-16 18:09:36.000000000 +0100
@@ -1,5 +1,5 @@
/* Extended regular expression matching and search library.
- Copyright (C) 2002 Free Software Foundation, Inc.
+ Copyright (C) 2002, 2003 Free Software Foundation, Inc.
This file is part of the GNU C Library.
Contributed by Isamu Hasegawa <isamu@yamato.ibm.com>.
@@ -752,6 +752,7 @@ re_compile_internal (preg, pattern, leng
{
re_free (dfa);
preg->buffer = NULL;
+ preg->allocated = 0;
return err;
}
#ifdef DEBUG
@@ -765,6 +766,7 @@ re_compile_internal (preg, pattern, leng
{
re_free (dfa);
preg->buffer = NULL;
+ preg->allocated = 0;
return err;
}
@@ -792,6 +794,7 @@ re_compile_internal (preg, pattern, leng
re_compile_internal_free_return:
free_dfa_content (dfa);
preg->buffer = NULL;
+ preg->allocated = 0;
}
return err;
Jakub
More information about the Libc-hacker
mailing list