This is the mail archive of the glibc-bugs@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]

[Bug string/21771] New: Incorrect value of wcrtomb


https://sourceware.org/bugzilla/show_bug.cgi?id=21771

            Bug ID: 21771
           Summary: Incorrect value of wcrtomb
           Product: glibc
           Version: 2.23
            Status: UNCONFIRMED
          Severity: normal
          Priority: P2
         Component: string
          Assignee: unassigned at sourceware dot org
          Reporter: luckboy at vp dot pl
  Target Milestone: ---

I found bug of wcrtomb for first argument as NULL. If first argument of wcrtomb
is NULL, wcrtomb returns incorrect value. This program shows the problem:

#include <limits.h>
#include <locale.h>
#include <stdio.h>
#include <string.h>
#include <wchar.h>

int main(void)
{
    char buf[MB_LEN_MAX];
    mbstate_t state;
    setlocale(LC_ALL, "en_US.UTF-8");
    memset(&state, 0, sizeof(mbstate_t));
    printf("%ld\n", (long) wcrtomb(NULL, L'\u0104', &state));
    memset(&state, 0, sizeof(mbstate_t));
    printf("%ld\n", (long) wcrtomb(buf, L'\u0104', &state));
    return 0;
}

Result of this below program:

1
2

-- 
You are receiving this mail because:
You are on the CC list for the bug.

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