commit c8b98df43be4c4b8bd2026d517b4962da91a9224
parent 2df53810a37e09f40929c9e51c61216d1fbf6002
Author: Roberto E. Vargas Caballero <roberto.vargas@midokura.com>
Date: Tue, 16 Aug 2022 13:39:41 +0200
libc/fputs: Fix return value
When an empty string was passed to fputs it returned
an uninitialized value.
Diffstat:
1 file changed, 3 insertions(+), 1 deletion(-)
diff --git a/src/libc/stdio/fputs.c b/src/libc/stdio/fputs.c
@@ -3,10 +3,12 @@
#undef fputs
int
-fputs(const char * restrict bp, FILE * restrict fp)
+fputs(const char *restrict bp, FILE *restrict fp)
{
int r, ch;
+ r = 0;
+
while ((ch = *bp++) != '\0')
r = putc(ch, fp);