Fix heap-use-after-free

This commit is contained in:
Alexey Rybalchenko 2021-06-24 11:19:06 +02:00 committed by Dennis Klein
parent 4fdf9d340b
commit ac3293fcc6

View File

@ -392,10 +392,10 @@ void Cmds::Deserialize(const string& str, const Format type)
const flatbuffers::Vector<flatbuffers::Offset<FBCommand>>* cmds = nullptr; const flatbuffers::Vector<flatbuffers::Offset<FBCommand>>* cmds = nullptr;
flatbuffers::Parser parser;
if (type == Format::Binary) { if (type == Format::Binary) {
cmds = cmd::GetFBCommands(const_cast<char*>(str.c_str()))->commands(); cmds = cmd::GetFBCommands(const_cast<char*>(str.c_str()))->commands();
} else { // Type == Format::JSON } else { // Type == Format::JSON
flatbuffers::Parser parser;
if (!parser.Parse(commandsFormatDefFbs)) { if (!parser.Parse(commandsFormatDefFbs)) {
throw CommandFormatError("Deserialize couldn't parse commands format"); throw CommandFormatError("Deserialize couldn't parse commands format");
} }