From 7f8735d84baeff4d41182d0682f8bf4aeaa07c8c Mon Sep 17 00:00:00 2001 From: Bruce Hill Date: Tue, 24 Jun 2025 12:54:49 -0400 Subject: Sanity check --- src/stdlib/text.c | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) (limited to 'src/stdlib') diff --git a/src/stdlib/text.c b/src/stdlib/text.c index 2107c1df..9dedccdd 100644 --- a/src/stdlib/text.c +++ b/src/stdlib/text.c @@ -1617,8 +1617,10 @@ public void Text$serialize(const void *obj, FILE *out, Table_t *pointers, const public void Text$deserialize(FILE *in, void *out, List_t *pointers, const TypeInfo_t *info) { (void)info; - int64_t len = -1; + int64_t len = 0; Int64$deserialize(in, &len, pointers, &Int64$info); + if (len < 0) + fail("Cannot deserialize text with a negative length!"); char *buf = GC_MALLOC_ATOMIC((size_t)len+1); if (fread(buf, sizeof(char), (size_t)len, in) != (size_t)len) fail("Not enough data in stream to deserialize"); -- cgit v1.2.3