Skip to content

Commit

Permalink
fix for ubuntu
Browse files Browse the repository at this point in the history
  • Loading branch information
vztpv authored Oct 4, 2023
1 parent cae4a8a commit 8a8bca3
Showing 1 changed file with 13 additions and 2 deletions.
15 changes: 13 additions & 2 deletions claujson.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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;
}

Expand Down

0 comments on commit 8a8bca3

Please sign in to comment.