fix return value computation in one code path of wcsnrtombs
authorRich Felker <dalias@aerifal.cx>
Thu, 18 Dec 2014 21:42:21 +0000 (16:42 -0500)
committerRich Felker <dalias@aerifal.cx>
Thu, 18 Dec 2014 21:42:21 +0000 (16:42 -0500)
the affected code was wrongly counting characters instead of bytes.

src/multibyte/wcsnrtombs.c

index 7eb05d4..ee4a534 100644 (file)
@@ -40,7 +40,7 @@ size_t wcsnrtombs(char *restrict dst, const wchar_t **restrict wcs, size_t wn, s
                ws++; wn--;
                /* safe - this loop runs fewer than sizeof(buf) times */
                s+=l; n-=l;
-               cnt++;
+               cnt += l;
        }
        if (dst) *wcs = ws;
        return cnt;