From c6f3818a5c852b26eca56a86d9a4d7f783fcff78 Mon Sep 17 00:00:00 2001 From: ahmedsamyh Date: Thu, 27 Mar 2025 02:54:12 +0500 Subject: [PATCH] [commonlib.h] Fix sv_to_cstr(). --- commonlib.h | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/commonlib.h b/commonlib.h index 2cb0b89..9aa11b3 100644 --- a/commonlib.h +++ b/commonlib.h @@ -607,8 +607,12 @@ void c_sv_trim(c_String_view* sv){ } char* c_sv_to_cstr(c_String_view sv){ - char* res = (char*)calloc(1, sizeof(char)*sv.count); + char* res = (char*)malloc(sizeof(char)*(sv.count + 1)); + if (res == NULL) { + C_ASSERT(false, "Buy more RAM bruh"); + } C_MEMCPY(res, sv.data, sv.count); + res[sv.count] = '\0'; return res; } -- 2.39.5