Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Browse files
Browse the repository at this point in the history
Fix unnecessary overallocation due to incomplete character
When incomplete characters are found at the end of a string the code ran amok and allocated lots of memory. Stricter limits are now in place.
- Loading branch information
Ulrich Drepper
committed
May 28, 2011
1 parent
4f03107
commit 8887a92
Showing
6 changed files
with
70 additions
and
16 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,36 @@ | ||
// BZ 12811 | ||
#include <regex.h> | ||
#include <stdio.h> | ||
#include <locale.h> | ||
|
||
static int | ||
do_test (void) | ||
{ | ||
char buf[1000]; | ||
regex_t preg; | ||
if (setlocale (LC_CTYPE, "de_DE.UTF-8") == NULL) | ||
{ | ||
puts ("setlocale failed"); | ||
return 1; | ||
} | ||
|
||
int e = regcomp (&preg, ".*ab", REG_ICASE); | ||
if (e != 0) | ||
{ | ||
regerror (e, &preg, buf, sizeof (buf)); | ||
printf ("regcomp = %d \"%s\"\n", e, buf); | ||
return 1; | ||
} | ||
|
||
// Incomplete character at the end of the buffer | ||
e = regexec (&preg, "aaaaaaaaaaaa\xc4", 0, NULL, 0); | ||
|
||
regfree (&preg); | ||
regerror (e, &preg, buf, sizeof (buf)); | ||
printf ("regexec = %d \"%s\"\n", e, buf); | ||
|
||
return e != REG_NOMATCH; | ||
} | ||
|
||
#define TEST_FUNCTION do_test () | ||
#include "../test-skeleton.c" |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters