aboutsummaryrefslogtreecommitdiffstats
path: root/main/musl/0011-fix-return-value-computation-in-one-code-path-of-wcs.patch
blob: 60d275aa08dcc3f574a72e4fd9bee5d888faa46d (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
From 2e1ae3b6b9331383ba5eaa7cb47373a8bea073d1 Mon Sep 17 00:00:00 2001
From: Rich Felker <dalias@aerifal.cx>
Date: Thu, 18 Dec 2014 16:42:21 -0500
Subject: [PATCH] fix return value computation in one code path of wcsnrtombs

the affected code was wrongly counting characters instead of bytes.
---
 src/multibyte/wcsnrtombs.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/src/multibyte/wcsnrtombs.c b/src/multibyte/wcsnrtombs.c
index 7eb05d4..ee4a534 100644
--- a/src/multibyte/wcsnrtombs.c
+++ b/src/multibyte/wcsnrtombs.c
@@ -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;
-- 
2.3.3