This is the mail archive of the
glibc-bugs@sourceware.org
mailing list for the glibc project.
[Bug libc/16950] New: mbrtowc on empty buffer returns 0, should return (size_t) -2
- From: "eggert at gnu dot org" <sourceware-bugzilla at sourceware dot org>
- To: glibc-bugs at sourceware dot org
- Date: Fri, 16 May 2014 01:15:52 +0000
- Subject: [Bug libc/16950] New: mbrtowc on empty buffer returns 0, should return (size_t) -2
- Auto-submitted: auto-generated
https://sourceware.org/bugzilla/show_bug.cgi?id=16950
Bug ID: 16950
Summary: mbrtowc on empty buffer returns 0, should return
(size_t) -2
Product: glibc
Version: 2.19
Status: NEW
Severity: normal
Priority: P2
Component: libc
Assignee: unassigned at sourceware dot org
Reporter: eggert at gnu dot org
CC: drepper.fsp at gmail dot com
Created attachment 7602
--> https://sourceware.org/bugzilla/attachment.cgi?id=7602&action=edit
demonstrate the mbrtowc-on-empty-buffer bug
Invoking mbrtowc (&wc, buf, 0, &mbs) should return (size_t) -2, because an
empty buffer's zero bytes "contribute to an incomplete but potentially valid
character", which is what POSIX says (size_t) -2 means. However, mbrtowc
returns 0. This is incorrect, as 0 should be returned only if the empty
buffer's zero bytes "complete the character that corresponds to the null wide
character", which is not what's happening here.
Other platforms I've tried seem to get this right, e.g., Solaris 10.
Compile and run the attached program mbrtowc-bug.c to demonstrate the bug. It
outputs "mbrtowc (A, B, 0, D) == 0x0, should be 0xfffffffffffffffe".
--
You are receiving this mail because:
You are on the CC list for the bug.