should mbrtowc(&wc, "", 1, &ps) set wc?
Bruno Haible
haible@ilog.fr
Sun Nov 12 11:33:00 GMT 2000
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
> space.
No. And by calling mbrtowc(pwc,s,n,ps) you are allowing the function
to inspect the bytes s[0], ..., 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.
Bruno
More information about the Libc-alpha
mailing list