aboutsummaryrefslogtreecommitdiff
path: root/src/stdlib
diff options
context:
space:
mode:
authorBruce Hill <bruce@bruce-hill.com>2025-06-24 12:54:49 -0400
committerBruce Hill <bruce@bruce-hill.com>2025-06-24 12:54:49 -0400
commit7f8735d84baeff4d41182d0682f8bf4aeaa07c8c (patch)
tree20c238eefa28ece4b08953079afc1b2c6bd5ed35 /src/stdlib
parentc09a4eece687c23846b922ec2ec8740859aaa210 (diff)
Sanity check
Diffstat (limited to 'src/stdlib')
-rw-r--r--src/stdlib/text.c4
1 files changed, 3 insertions, 1 deletions
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");