summaryrefslogtreecommitdiff
path: root/tests/test_wcsnrtombs_static.c (follow)
AgeCommit message (Collapse)Author
39 hoursFix a bug in wcsnrtombsjvoisin
__d is a char * destination buffer, so __b is already the byte capacity. Dividing by sizeof(wchar_t) makes no sense here, it was likely copy-pasted from mbsnrtowcs (where the destination is wchar_t *). The first branch also fails to limit __n (the byte write cap) to __b, so overflows are possible when a wide character produces multi-byte output. The second branch (else) correctly limits __n to __b. This commit replaces the broken two-branch logic with the simple correct pattern matching wcsrtombs, and adds two tests two prove that nothing broke.