From dff94a41be8f3099c4a1df2256e1dcc8b1b45af6 Mon Sep 17 00:00:00 2001 From: Lion Kortlepel Date: Thu, 10 Nov 2022 18:51:43 +0100 Subject: [PATCH] fix potential out of bounds exception in GetPidVid --- src/TServer.cpp | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/src/TServer.cpp b/src/TServer.cpp index 56e6f74..5994540 100644 --- a/src/TServer.cpp +++ b/src/TServer.cpp @@ -25,6 +25,10 @@ struct VehiclePacket { static std::optional> 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);