This is the mail archive of the
glibc-bugs@sourceware.org
mailing list for the glibc project.
[Bug string/21771] New: Incorrect value of wcrtomb
- From: "luckboy at vp dot pl" <sourceware-bugzilla at sourceware dot org>
- To: glibc-bugs at sourceware dot org
- Date: Fri, 14 Jul 2017 16:07:48 +0000
- Subject: [Bug string/21771] New: Incorrect value of wcrtomb
- Auto-submitted: auto-generated
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.