1
0
mirror of https://sourceware.org/git/glibc.git synced 2025-07-29 11:41:21 +03:00

regex_internal.c: don't assume WEOF fits in wchar_t

This commit is contained in:
Ulrich Drepper
2010-01-22 10:17:45 -08:00
parent 0dae5d4ec1
commit 4f08104cbf
2 changed files with 11 additions and 5 deletions

View File

@ -1,5 +1,9 @@
2010-01-22 Jim Meyering <jim@meyering.net> 2010-01-22 Jim Meyering <jim@meyering.net>
[BZ #11186]
* posix/regex_internal.c (re_string_skip_chars): Don't assume WEOF
fits in wchar_t. Problem reported by Eric Blake.
[BZ #11185] [BZ #11185]
* posix/regex_internal.c (re_string_reconstruct): Remove declaration * posix/regex_internal.c (re_string_reconstruct): Remove declaration
and stores into set-but-not-used local, "q". and stores into set-but-not-used local, "q".

View File

@ -489,16 +489,16 @@ re_string_skip_chars (re_string_t *pstr, int new_raw_idx, wint_t *last_wc)
mbstate_t prev_st; mbstate_t prev_st;
int rawbuf_idx; int rawbuf_idx;
size_t mbclen; size_t mbclen;
wchar_t wc = WEOF; wint_t wc = WEOF;
/* Skip the characters which are not necessary to check. */ /* Skip the characters which are not necessary to check. */
for (rawbuf_idx = pstr->raw_mbs_idx + pstr->valid_raw_len; for (rawbuf_idx = pstr->raw_mbs_idx + pstr->valid_raw_len;
rawbuf_idx < new_raw_idx;) rawbuf_idx < new_raw_idx;)
{ {
int remain_len; wchar_t wc2;
remain_len = pstr->len - rawbuf_idx; int remain_len = pstr->len - rawbuf_idx;
prev_st = pstr->cur_state; prev_st = pstr->cur_state;
mbclen = __mbrtowc (&wc, (const char *) pstr->raw_mbs + rawbuf_idx, mbclen = __mbrtowc (&wc2, (const char *) pstr->raw_mbs + rawbuf_idx,
remain_len, &pstr->cur_state); remain_len, &pstr->cur_state);
if (BE (mbclen == (size_t) -2 || mbclen == (size_t) -1 || mbclen == 0, 0)) if (BE (mbclen == (size_t) -2 || mbclen == (size_t) -1 || mbclen == 0, 0))
{ {
@ -510,10 +510,12 @@ re_string_skip_chars (re_string_t *pstr, int new_raw_idx, wint_t *last_wc)
mbclen = 1; mbclen = 1;
pstr->cur_state = prev_st; pstr->cur_state = prev_st;
} }
else
wc = (wint_t) wc2;
/* Then proceed the next character. */ /* Then proceed the next character. */
rawbuf_idx += mbclen; rawbuf_idx += mbclen;
} }
*last_wc = (wint_t) wc; *last_wc = wc;
return rawbuf_idx; return rawbuf_idx;
} }
#endif /* RE_ENABLE_I18N */ #endif /* RE_ENABLE_I18N */