From 0c6ea4790dd6ad4101ac3c76172075e44833c106 Mon Sep 17 00:00:00 2001 From: Andy Piper Date: Sat, 27 Jan 2024 16:36:35 +0000 Subject: [PATCH] AP_Common: fix initialization of ExpandingString so that it can be used on the stack zero out passed in buffers for ExpandingString --- libraries/AP_Common/ExpandingString.cpp | 7 +++++++ libraries/AP_Common/ExpandingString.h | 2 ++ 2 files changed, 9 insertions(+) diff --git a/libraries/AP_Common/ExpandingString.cpp b/libraries/AP_Common/ExpandingString.cpp index 9be2b3a91a..a3e7a8b401 100644 --- a/libraries/AP_Common/ExpandingString.cpp +++ b/libraries/AP_Common/ExpandingString.cpp @@ -25,6 +25,13 @@ extern const AP_HAL::HAL& hal; #define EXPAND_INCREMENT 512 +ExpandingString::ExpandingString(char* s, uint32_t total_len) : buf(0) +{ + set_buffer(s, total_len, 0); + memset(buf, 0, buflen); +} + + /* expand the string buffer */ diff --git a/libraries/AP_Common/ExpandingString.h b/libraries/AP_Common/ExpandingString.h index 2561332f3e..d92882e1b3 100644 --- a/libraries/AP_Common/ExpandingString.h +++ b/libraries/AP_Common/ExpandingString.h @@ -24,6 +24,8 @@ class ExpandingString { public: + ExpandingString() : buf(0), buflen(0), used(0), allocation_failed(false), external_buffer(false) {} + ExpandingString(char* s, uint32_t total_len); const char *get_string(void) const { return buf;