#18350 closed bug (fixed)

mbrtoc32 returns wrong value for empty input

Reported by: bhaible Owned by: nobody
Priority: normal Milestone: R1/beta5
Component: System/libroot.so Version: R1/beta4
Keywords: Cc:
Blocked By: Blocking:
Platform: All

Description

When given an empty input, the mbrtoc32 function should return (size_t)(-2). This is clear from ISO C 23, section 7.30.1.5: "If s is not a null pointer, the mbrtoc32 function inspects at most n bytes beginning with the byte pointed to by s to determine the number of bytes needed to complete the next multibyte character (including any shift sequences)." If n is 0, the mbrtoc32 function cannot inspect anything, thus no complete multibyte character can be parsed in such a call.

How to reproduce:

$ gcc -Wall -ggdb foo.c
$ ./a.out
ret = 0
Abort

Attachments (1)

foo.c (279 bytes ) - added by bhaible 14 months ago.
test case

Download all attachments as: .zip

Change History (2)

by bhaible, 14 months ago

Attachment: foo.c added

test case

comment:1 by waddlesplash, 13 months ago

Milestone: UnscheduledR1/beta5
Resolution: fixed
Status: newclosed

Fixed in hrev56914.

Note: See TracTickets for help on using tickets.