summaryrefslogtreecommitdiffstats
path: root/lib/libc/regex/regcomp.c
diff options
context:
space:
mode:
Diffstat (limited to 'lib/libc/regex/regcomp.c')
-rw-r--r--lib/libc/regex/regcomp.c8
1 files changed, 5 insertions, 3 deletions
diff --git a/lib/libc/regex/regcomp.c b/lib/libc/regex/regcomp.c
index e943374..9664084 100644
--- a/lib/libc/regex/regcomp.c
+++ b/lib/libc/regex/regcomp.c
@@ -1942,14 +1942,16 @@ struct re_guts *g;
if (p->error != 0)
return;
- g->charjump = malloc((UCHAR_MAX+1) * sizeof(int));
+ g->charjump = malloc((NC + 1) * sizeof(int));
if (g->charjump == NULL) /* Not a fatal error */
return;
+ /* Adjust for signed chars, if necessary */
+ g->charjump = &g->charjump[-(CHAR_MIN)];
/* If the character does not exist in the pattern, the jump
* is equal to the number of characters in the pattern.
*/
- for (ch = 0; ch < (UCHAR_MAX+1); ch++)
+ for (ch = CHAR_MIN; ch < (CHAR_MAX + 1); ch++)
g->charjump[ch] = g->mlen;
/* If the character does exist, compute the jump that would
@@ -1958,7 +1960,7 @@ struct re_guts *g;
* is the first one that would be matched).
*/
for (mindex = 0; mindex < g->mlen; mindex++)
- g->charjump[(unsigned char)g->must[mindex]] = g->mlen - mindex - 1;
+ g->charjump[g->must[mindex]] = g->mlen - mindex - 1;
}
/*
OpenPOWER on IntegriCloud