From c13cdcdd36f8de2f6ce4ba1196cd882a4064771e Mon Sep 17 00:00:00 2001 From: Walther Chen Date: Tue, 17 Dec 2024 16:15:24 +0700 Subject: [PATCH] in new_struct_to_str, fix uaf --- lib/std/core/string.c3 | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/lib/std/core/string.c3 b/lib/std/core/string.c3 index 31275f81e..aa17a0cb3 100644 --- a/lib/std/core/string.c3 +++ b/lib/std/core/string.c3 @@ -757,8 +757,8 @@ macro String new_struct_to_str(x, Allocator allocator = allocator::heap()) { s.new_init(allocator: mem); io::fprint(&s, x)!!; + return s.copy_str(allocator); }; - return s.copy_str(allocator); } -macro String temp_struct_to_str(x) => new_struct_to_str(x, allocator::temp()); \ No newline at end of file +macro String temp_struct_to_str(x) => new_struct_to_str(x, allocator::temp());