From 18af3053f39dd92c5370e9d653aa8207243c3371 Mon Sep 17 00:00:00 2001 From: Intel A80486DX2-66 Date: Sun, 10 Mar 2024 15:06:20 +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 a98c5f4..9a56378 100644 --- a/c-programming/io/freadln.c +++ b/c-programming/io/freadln.c @@ -37,8 +37,10 @@ int freadln(FILE* f, char** output, size_t* length_out) { freadln_length_type length = 0; // initial length *output = malloc((length + 1) * sizeof(char)); - if (*output == NULL) + if (*output == NULL) { + errno = EINVAL; return freadln_ERROR; + } int character; while ((character = fgetc(f)) != EOF