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 7eb05d459ab826fbba890d52796302d799b1b251..ee4a534ab0c5131991a9af15c612f63391cf8d27 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;