fix potential out of bounds exception in GetPidVid

This commit is contained in:
Lion Kortlepel
2022-11-10 18:51:43 +01:00
parent 79ee5915b4
commit dff94a41be

View File

@@ -25,6 +25,10 @@ struct VehiclePacket {
static std::optional<std::pair<int, int>> GetPidVid(const std::string& str) {
auto IDSep = str.find('-');
if (IDSep == std::string::npos) {
beammp_debugf("Invalid packet: Could not parse pid/vid from packet, as there is no '-' separator: '{}'", str);
return std::nullopt;
}
std::string pid = str.substr(0, IDSep);
std::string vid = str.substr(IDSep + 1);