This is the mail archive of the
mailing list for the glibc project.
Re: should mbrtowc(&wc, "", 1, &ps) set wc?
- To: libc-alpha at sources dot redhat dot com
- Subject: Re: should mbrtowc(&wc, "", 1, &ps) set wc?
- From: Bruno Haible <haible at ilog dot fr>
- Date: Sun, 12 Nov 2000 20:32:02 +0100 (CET)
- Cc: Edmund GRIMLEY EVANS <edmundo at rano dot org>
- References: <20001111211606.P13595@rano.org>
Edmund GRIMLEY EVANS writes:
> mbrtowc(&wc, "\302\240", (size_t)(-1), &ps) returns -1. So does
> mbrtowc(&wc, s, (char *)0 - s, &ps), where s is "\302\240"
> I don't know whether strings are allowed to wrap around the address
No. And by calling mbrtowc(pwc,s,n,ps) you are allowing the function
to inspect the bytes s, ..., s[n-1]. Quoting ISO C 99:
"If s is not a null pointer, the mbrtowc function inspects at most
n bytes beginning with the byte pointed to by s to determine the
number of bytes needed ..."
Thus the value for n that you pass here is invalid.