diff --git a/src/algorithms/PVT/libs/rtcm.h b/src/algorithms/PVT/libs/rtcm.h index b124203ba..2cccef89d 100644 --- a/src/algorithms/PVT/libs/rtcm.h +++ b/src/algorithms/PVT/libs/rtcm.h @@ -44,6 +44,7 @@ #include #include #include +#include // for min #include #include // for size_t #include @@ -593,7 +594,7 @@ private: inline void encode_header() { char header[header_length + 1] = ""; - std::snprintf(header, header_length, "GS%4d", static_cast(body_length_)); + std::snprintf(header, header_length + 1, "GS%4d", std::min(static_cast(body_length_), static_cast(max_body_length))); std::memcpy(data_, header, header_length); }