From 46555c558870e8b96f1ce361d74fc404ca13c471 Mon Sep 17 00:00:00 2001 From: Bruce Hill Date: Tue, 6 May 2025 22:27:59 -0400 Subject: Check return values --- src/stdlib/c_strings.c | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) (limited to 'src/stdlib/c_strings.c') diff --git a/src/stdlib/c_strings.c b/src/stdlib/c_strings.c index c153a8a9..860a69ff 100644 --- a/src/stdlib/c_strings.c +++ b/src/stdlib/c_strings.c @@ -64,7 +64,8 @@ static void CString$deserialize(FILE *in, void *out, List_t *pointers, const Typ int64_t len = -1; Int64$deserialize(in, &len, pointers, &Int64$info); char *str = GC_MALLOC_ATOMIC((size_t)len+1); - fread(str, sizeof(char), (size_t)len, in); + if (fread(str, sizeof(char), (size_t)len, in) != (size_t)len) + fail("Not enough data in stream to deserialize"); str[len+1] = '\0'; *(const char**)out = str; } -- cgit v1.2.3