This is the mail archive of the libc-help@sourceware.org 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]
Other format: [Raw text]

Re: Pointer to invalid multibyte sequence in mbsnrtowcs()


On 12/19/2016 05:52 AM, Igor Liferenko wrote:

Contrary to mbsnrtowcs(3), *src is not left pointing to the invalid multibyte
sequence after mbsnrtowcs() completes.

There are two possible cases:

1) incomplete multibyte character is at the end of input buffer *)
2) incomplete multibyte character is not at the end of input buffer *)

*) - end of buffer is determined by nms argument.

But in either case *src is unchanged. Am I missing something obvious or it is
a bug?

Consider the following examples:

Example 1 (at the end of buffer):

    #include <locale.h>
    #include <wchar.h>
    #include <stdio.h>
    #include <string.h>
    int main(void)
    {
      setlocale(LC_CTYPE, "en_US.UTF-8");
      char *s = "\321\216\321";

I'm not sure if this example demonstrates the behavior you describe because the string starts with an invalid multibyte sequence, so I would expect mbsnrtowcs not t advance the read pointer in this case.

Thanks,
Florian


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