diff options
author | Sylvain Joubert <joubert.sy@gmail.com> | 2019-11-18 14:23:01 (GMT) |
---|---|---|
committer | Sylvain Joubert <joubert.sy@gmail.com> | 2019-11-19 19:06:31 (GMT) |
commit | b4ef7fbaa8257254abba0d7847941baf78fdb6ed (patch) | |
tree | 3f2c8851e7ac9955ac861b09c1e399dd3acb0563 /Source/CursesDialog/cmCursesMainForm.h | |
parent | 3520208cbd0ebf9f3db1a9711b49286462cd7e54 (diff) | |
download | CMake-b4ef7fbaa8257254abba0d7847941baf78fdb6ed.zip CMake-b4ef7fbaa8257254abba0d7847941baf78fdb6ed.tar.gz CMake-b4ef7fbaa8257254abba0d7847941baf78fdb6ed.tar.bz2 |
ccmake: Fix crash with cache entries almost the size of the window
The previous code:
if (curFieldLen < width) {
...
strncpy(bar + curFieldLen + 2, help, width - curFieldLen - 2);
was not correctly guarded against cache entries whose size were exactly
1 or 2 characters short of the window size.
"if (curFieldLen - 2 < width)" would have prevented a copy of
negative/max_int characters and a subsequent crash.
The whole method was modernized with std::string instead of char*
Diffstat (limited to 'Source/CursesDialog/cmCursesMainForm.h')
-rw-r--r-- | Source/CursesDialog/cmCursesMainForm.h | 6 |
1 files changed, 4 insertions, 2 deletions
diff --git a/Source/CursesDialog/cmCursesMainForm.h b/Source/CursesDialog/cmCursesMainForm.h index 598fbdf..b7c204d 100644 --- a/Source/CursesDialog/cmCursesMainForm.h +++ b/Source/CursesDialog/cmCursesMainForm.h @@ -10,6 +10,8 @@ #include <string> #include <vector> +#include <cm/optional> + #include "cmCursesCacheEntryComposite.h" #include "cmCursesForm.h" #include "cmCursesStandardIncludes.h" @@ -67,8 +69,8 @@ public: * exception is during a resize. The optional argument specifies the * string to be displayed in the status bar. */ - void UpdateStatusBar() override { this->UpdateStatusBar(nullptr); } - virtual void UpdateStatusBar(const char* message); + void UpdateStatusBar() override { this->UpdateStatusBar(cm::nullopt); } + void UpdateStatusBar(cm::optional<std::string> message); /** * Display current commands and their keys on the toolbar. This |