From 99386beec7da8531b9f84ba87ac975f863618c8d Mon Sep 17 00:00:00 2001 From: jgromes Date: Wed, 14 Apr 2021 19:24:03 +0200 Subject: [PATCH] [RTTY] Fixed dynamic memory issue with ITA2Strings (#278) --- src/protocols/RTTY/RTTY.cpp | 2 ++ src/protocols/RTTY/RTTY.h | 2 +- 2 files changed, 3 insertions(+), 1 deletion(-) diff --git a/src/protocols/RTTY/RTTY.cpp b/src/protocols/RTTY/RTTY.cpp index 30fae58b..5ee05efc 100644 --- a/src/protocols/RTTY/RTTY.cpp +++ b/src/protocols/RTTY/RTTY.cpp @@ -3,12 +3,14 @@ ITA2String::ITA2String(char c) { _len = 1; + _str = new char[1]; _str[0] = c; _ita2Len = 0; } ITA2String::ITA2String(const char* str) { _len = strlen(str); + _str = new char[_len]; strcpy(_str, str); _ita2Len = 0; } diff --git a/src/protocols/RTTY/RTTY.h b/src/protocols/RTTY/RTTY.h index 6eab5fec..ac8188e9 100644 --- a/src/protocols/RTTY/RTTY.h +++ b/src/protocols/RTTY/RTTY.h @@ -67,7 +67,7 @@ class ITA2String { #ifdef RADIOLIB_STATIC_ONLY char _str[RADIOLIB_STATIC_ARRAY_SIZE]; #else - char* _str = new char[1]; + char* _str; #endif size_t _len; size_t _ita2Len;