Skip to content

Commit

Permalink
json serializing not allocating memory
Browse files Browse the repository at this point in the history
  • Loading branch information
101001000 committed Sep 9, 2023
1 parent 8f5a1fe commit d8b1419
Showing 1 changed file with 4 additions and 1 deletion.
5 changes: 4 additions & 1 deletion src/CommandManager.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -289,7 +289,10 @@ void CommandManager::get_render_info() {

json_info["samples"] = render_info.samples;

render_info_msg.data = (void*)(boost::json::serialize(json_info).c_str());
// RAII....
char* cstr_data = new char[boost::json::serialize(json_info).size() + 1];
std::strcpy(cstr_data, boost::json::serialize(json_info).c_str());
render_info_msg.data = static_cast<void*>(cstr_data);
render_info_msg.data_format = Message::DataFormat::JSON;
render_info_msg.data_size = boost::json::serialize(json_info).size();
render_info_msg.type = Message::Type::DATA;
Expand Down

0 comments on commit d8b1419

Please sign in to comment.