From 6406f05eb2d12c4383d1a145fe2ccbdb7a5e5c6b Mon Sep 17 00:00:00 2001 From: Lephenixnoir Date: Sun, 3 Sep 2023 19:03:48 +0200 Subject: [PATCH] shell: fix crash for commands without a long description --- shell/main.cpp | 14 ++++++++------ 1 file changed, 8 insertions(+), 6 deletions(-) diff --git a/shell/main.cpp b/shell/main.cpp index a52e45a..81dacdf 100644 --- a/shell/main.cpp +++ b/shell/main.cpp @@ -27,12 +27,14 @@ ShellCommand::ShellCommand(std::string _name, ShellFunction _function, function {_function}, completer {_completer}, short_description {_shortd} { - /* Left trim */ - _longd.erase(0, _longd.find_first_not_of("\n")); - /* Right trim */ - int r = _longd.size(); - while(r > 0 && _longd[--r] == '\n') {} - _longd.erase(r + 1, _longd.size()); + if(_longd.size()) { + /* Left trim */ + _longd.erase(0, _longd.find_first_not_of("\n")); + /* Right trim */ + int r = _longd.size(); + while(r > 0 && _longd[--r] == '\n') {} + _longd.erase(r + 1, _longd.size()); + } this->long_description = _longd; commands[_name] = this;