- edited description
wcsrtombs(3) doesn't update src wide character pointer when found illegal wide character.
Issue #66
closed
http://pubs.opengroup.org/onlinepubs/9699919799/functions/wcsrtombs.html
spec says:
Conversion shall stop earlier in the following cases:
- When a code is reached that does not correspond to a valid character
and:
the pointer object pointed to by src shall be assigned (...) the address just past the last wide character converted (...)
but our implementation doesn't update src wide character pointer when found illegal wide character.
try following testcase:
#include <assert.h>
#include <locale.h>
#include <limits.h>
#include <wchar.h>
#include <stdlib.h>
#include <string.h>
int
main(void)
{
wchar_t wcs[] = { L'A', 0xFFFF, L'\0' };
const wchar_t *pwcs = wcs;
char s[MB_LEN_MAX * 3];
mbstate_t st;
size_t ret;
setlocale(LC_CTYPE, "C");
memset(&st, 0, sizeof(st));
ret = wcsrtombs(s, &pwcs, sizeof(s), &st);
assert(ret == (size_t)-1);
assert(pwcs == &wcs[1]);
assert(s[0] == 'A');
}
Comments (4)
-
reporter -
reporter Solaris, glibc2, OpenBSD, Cygwin works fine, but NetBSD/FreeBSD may fail.
-
reporter - changed status to resolved
BUGFIX: Issue
#66-- wcsrtombs(3) doesn't update src wide character pointer when found illegal wide character.→ <<cset 2c219971f1d5>>
-
reporter - edited description
- changed status to closed
- Log in to comment