From eabc7527032b0889917edac0ded83dad8a9921e3 Mon Sep 17 00:00:00 2001 From: jgromes Date: Wed, 18 Oct 2023 17:47:09 +0200 Subject: [PATCH] [APRS] Fix array length calculation in static only mode --- src/protocols/APRS/APRS.cpp | 14 +++++++------- 1 file changed, 7 insertions(+), 7 deletions(-) diff --git a/src/protocols/APRS/APRS.cpp b/src/protocols/APRS/APRS.cpp index 780dddf4..3458272e 100644 --- a/src/protocols/APRS/APRS.cpp +++ b/src/protocols/APRS/APRS.cpp @@ -35,14 +35,14 @@ int16_t APRSClient::begin(char sym, char* callsign, uint8_t ssid, bool alt) { } int16_t APRSClient::sendPosition(char* destCallsign, uint8_t destSSID, char* lat, char* lon, char* msg, char* time) { + size_t len = 1 + strlen(lat) + 1 + strlen(lon); + if(msg != NULL) { + len += 1 + strlen(msg); + } + if(time != NULL) { + len += strlen(time); + } #if !defined(RADIOLIB_STATIC_ONLY) - size_t len = 1 + strlen(lat) + 1 + strlen(lon); - if(msg != NULL) { - len += 1 + strlen(msg); - } - if(time != NULL) { - len += strlen(time); - } char* info = new char[len + 1]; #else char info[RADIOLIB_STATIC_ARRAY_SIZE];