From 34391f25f949581123c32b1cebedeca4ebcc3995 Mon Sep 17 00:00:00 2001 From: Jason Hall Date: Fri, 10 Apr 2020 21:23:10 +0100 Subject: [PATCH] Correct string size for classes and strings --- c/object.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/c/object.c b/c/object.c index 83ab3350..ebcf6b9a 100644 --- a/c/object.c +++ b/c/object.c @@ -419,7 +419,7 @@ char *setToString(Value value) { char *classToString(Value value) { ObjClass *klass = AS_CLASS(value); - char *classString = malloc(sizeof(char) * (klass->name->length + 6)); + char *classString = malloc(sizeof(char) * (klass->name->length + 7)); memcpy(classString, "name->chars, klass->name->length); memcpy(classString + 5 + klass->name->length, ">", 1); @@ -429,7 +429,7 @@ char *classToString(Value value) { char *instanceToString(Value value) { ObjInstance *instance = AS_INSTANCE(value); - char *instanceString = malloc(sizeof(char) * (instance->klass->name->length + 11)); + char *instanceString = malloc(sizeof(char) * (instance->klass->name->length + 12)); memcpy(instanceString, "<", 1); memcpy(instanceString + 1, instance->klass->name->chars, instance->klass->name->length); memcpy(instanceString + 1 + instance->klass->name->length, " instance>", 10);