Fix crash in command handling

This commit is contained in:
Federico Cecchetto 2022-03-02 00:33:17 +01:00
parent 628795139d
commit 4f18bce545

View File

@ -27,12 +27,19 @@ namespace network
const auto cmd_string = utils::string::to_lower(command);
auto& callbacks = get_callbacks();
const auto handler = callbacks.find(cmd_string);
if (handler == callbacks.end())
{
return false;
}
const auto offset = cmd_string.size() + 5;
if (message->cursize <= offset)
{
return false;
}
const std::string_view data(message->data + offset, message->cursize - offset);
handler->second(*address, data);