From 2e294a2047d009ea7606c92342d30f8af8ab3f39 Mon Sep 17 00:00:00 2001 From: Intel A80486DX2-66 Date: Sun, 2 Mar 2025 13:49:16 +0300 Subject: [PATCH] freadln.c: set errno to EINVAL if output is NULL --- c-programming/io/freadln.c | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/c-programming/io/freadln.c b/c-programming/io/freadln.c index 290b7df..82e20b0 100644 --- a/c-programming/io/freadln.c +++ b/c-programming/io/freadln.c @@ -27,8 +27,10 @@ int freadln(FILE* f, char** output, size_t* length_out) { * freadln_ERROR: an error occurred (see errno) */ - if (output == NULL) + if (output == NULL) { + errno = EINVAL; return freadln_ERROR; + } // NOTE: if the file is STDIN, flush STDOUT before waiting for input to // make sure a prompt is displayed