aboutsummaryrefslogtreecommitdiffstats
path: root/main/musl/fix-return-value-of-ungetc-when-argument-is-outside-.patch
blob: b03b1861dee1009d7ccc83d7f5c9c19d3a5d82cc (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
27
28
29
30
31
From f6ecd0c296181bf6a2a7f54e3406c846500e8e63 Mon Sep 17 00:00:00 2001
From: Rich Felker <dalias@aerifal.cx>
Date: Fri, 18 Oct 2019 21:11:44 -0400
Subject: [PATCH] fix return value of ungetc when argument is outside unsigned
 char range

aside from the special value EOF, ungetc is specified to accept and
convert values outside the range of unsigned char. conversion takes
place automatically as part of assignment when storing into the
buffer, but the return value is also required to be the resulting
converted value, and this requirement was not satisfied.

simplified from patch by Wang Jianjian.
---
 src/stdio/ungetc.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/src/stdio/ungetc.c b/src/stdio/ungetc.c
index 180673a4..bc629d4c 100644
--- a/src/stdio/ungetc.c
+++ b/src/stdio/ungetc.c
@@ -16,5 +16,5 @@ int ungetc(int c, FILE *f)
 	f->flags &= ~F_EOF;
 
 	FUNLOCK(f);
-	return c;
+	return (unsigned char)c;
 }
-- 
2.24.1