From 8a8bca37fc49d2ec122890843eef562990e71cfd Mon Sep 17 00:00:00 2001 From: DongWook Lee Date: Wed, 4 Oct 2023 09:59:33 +0900 Subject: [PATCH] fix for ubuntu --- claujson.cpp | 15 +++++++++++++-- 1 file changed, 13 insertions(+), 2 deletions(-) diff --git a/claujson.cpp b/claujson.cpp index c6900d2..06ed0e3 100644 --- a/claujson.cpp +++ b/claujson.cpp @@ -3990,8 +3990,19 @@ namespace claujson { StrStream& operator<<(StringView sv) { // chk! char buf[1024] = { 0 }; - memcpy_s(buf, 1024, sv.data(), sv.size()); - fmt::format_to(std::back_inserter(out), "{}", buf); + if (sv.size() >= 1024) { + char* new_buf = (char*)malloc(sizeof(char) * (sv.size() + 1)); + if (new_buf) { + memcpy(new_buf, sv.data(), sv.size()); + new_buf[sv.size()] = '\0'; + fmt::format_to(std::back_inserter(out), "{}", new_buf); + free(new_buf); + } + } + else { + memcpy(buf, sv.data(), sv.size()); + fmt::format_to(std::back_inserter(out), "{}", buf); + } return *this; }