From 45b0be8e7584f567acc1b593b1eba19aa9f54b0d Mon Sep 17 00:00:00 2001 From: Ivan FB <128452529+Ivansete-status@users.noreply.github.com> Date: Mon, 11 Dec 2023 08:50:03 +0100 Subject: [PATCH] waku_thread_response.nim: use correct alloc() proc to allocate response correctly (#2277) --- .../inter_thread_communication/waku_thread_response.nim | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/library/waku_thread/inter_thread_communication/waku_thread_response.nim b/library/waku_thread/inter_thread_communication/waku_thread_response.nim index c3005f4d7a..894c4d511a 100644 --- a/library/waku_thread/inter_thread_communication/waku_thread_response.nim +++ b/library/waku_thread/inter_thread_communication/waku_thread_response.nim @@ -6,6 +6,8 @@ import std/json, stew/results +import + ../../alloc type ResponseType {.pure.} = enum @@ -26,13 +28,11 @@ proc createShared*(T: type InterThreadResponse, if res.isOk(): let value = res.get() ret[].respType = ResponseType.OK - ret[].content = cast[cstring](allocShared0(value.len + 1)) - copyMem(ret[].content, unsafeAddr value, value.len + 1) + ret[].content = value.alloc() else: let error = res.error ret[].respType = ResponseType.ERR - ret[].content = cast[cstring](allocShared0(error.len + 1)) - copyMem(ret[].content, unsafeAddr error, error.len + 1) + ret[].content = res.error.alloc() return ret proc process*(T: type InterThreadResponse,