summaryrefslogtreecommitdiff
path: root/Source/CursesDialog/cmCursesMainForm.h
diff options
context:
space:
mode:
authorSylvain Joubert <joubert.sy@gmail.com>2019-11-18 15:23:01 +0100
committerSylvain Joubert <joubert.sy@gmail.com>2019-11-19 20:06:31 +0100
commitb4ef7fbaa8257254abba0d7847941baf78fdb6ed (patch)
tree3f2c8851e7ac9955ac861b09c1e399dd3acb0563 /Source/CursesDialog/cmCursesMainForm.h
parent3520208cbd0ebf9f3db1a9711b49286462cd7e54 (diff)
downloadcmake-b4ef7fbaa8257254abba0d7847941baf78fdb6ed.tar.gz
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.h6
1 files changed, 4 insertions, 2 deletions
diff --git a/Source/CursesDialog/cmCursesMainForm.h b/Source/CursesDialog/cmCursesMainForm.h
index 598fbdfba3..b7c204d64e 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