This is the mail archive of the libc-alpha@sources.redhat.com mailing list for the glibc project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]

Re: should mbrtowc(&wc, "", 1, &ps) set wc?


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

Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]