mirror of git://sourceware.org/git/glibc.git
(__mbrtowc): Set end of buffer correctly if s == NULL.
This commit is contained in:
parent
cffad2ae2a
commit
515ab778a7
|
@ -43,9 +43,7 @@ __mbrtowc (wchar_t *pwc, const char *s, size_t n, mbstate_t *ps)
|
||||||
const unsigned char *inbuf;
|
const unsigned char *inbuf;
|
||||||
char *outbuf = (char *) (pwc ?: buf);
|
char *outbuf = (char *) (pwc ?: buf);
|
||||||
|
|
||||||
/* Tell where we want the result. */
|
/* Set information for this step. */
|
||||||
data.__outbuf = outbuf;
|
|
||||||
data.__outbufend = outbuf + sizeof (wchar_t);
|
|
||||||
data.__invocation_counter = 0;
|
data.__invocation_counter = 0;
|
||||||
data.__internal_use = 1;
|
data.__internal_use = 1;
|
||||||
data.__is_last = 1;
|
data.__is_last = 1;
|
||||||
|
@ -55,13 +53,17 @@ __mbrtowc (wchar_t *pwc, const char *s, size_t n, mbstate_t *ps)
|
||||||
initial state. */
|
initial state. */
|
||||||
if (s == NULL)
|
if (s == NULL)
|
||||||
{
|
{
|
||||||
data.__outbuf = (char *) buf;
|
outbuf = (char *) buf;
|
||||||
s = "";
|
s = "";
|
||||||
n = 1;
|
n = 1;
|
||||||
temp_state = *data.__statep;
|
temp_state = *data.__statep;
|
||||||
data.__statep = &temp_state;
|
data.__statep = &temp_state;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/* Tell where we want the result. */
|
||||||
|
data.__outbuf = outbuf;
|
||||||
|
data.__outbufend = outbuf + sizeof (wchar_t);
|
||||||
|
|
||||||
/* Make sure we use the correct function. */
|
/* Make sure we use the correct function. */
|
||||||
update_conversion_ptrs ();
|
update_conversion_ptrs ();
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue