summaryrefslogtreecommitdiff
path: root/fluid
diff options
context:
space:
mode:
authorAlbrecht Schlosser <albrechts.fltk@online.de>2025-02-19 17:22:16 +0100
committerAlbrecht Schlosser <albrechts.fltk@online.de>2025-02-19 17:22:16 +0100
commiteaf5fb8d1153a1384db0c5ae645e36ef84a9da51 (patch)
tree7861659c030c4da7156fd2947a7c23c9125d4367 /fluid
parent45476d093cdea0aad0668bf5ecac0ec4bd34d970 (diff)
Fix buffer overflow warning [-Wstringop-truncation]
Note: this fixes the warning, but a better fix would be to use either strlcpy(), fl_strlcpy(), or a string type in 1.5.0 or higher.
Diffstat (limited to 'fluid')
-rw-r--r--fluid/fluid.cxx5
1 files changed, 2 insertions, 3 deletions
diff --git a/fluid/fluid.cxx b/fluid/fluid.cxx
index b63ebe672..c8b2292d1 100644
--- a/fluid/fluid.cxx
+++ b/fluid/fluid.cxx
@@ -1936,7 +1936,6 @@ void load_history() {
int i; // Looping var
int max_files;
-
fluid_prefs.get("recent_files", max_files, 5);
if (max_files > 10) max_files = 10;
@@ -1945,7 +1944,7 @@ void load_history() {
if (absolute_history[i][0]) {
// Make a shortened version of the filename for the menu...
Fl_String fn = fl_filename_shortened(absolute_history[i], 48);
- strncpy(relative_history[i], fn.c_str(), sizeof(relative_history[i]));
+ strncpy(relative_history[i], fn.c_str(), sizeof(relative_history[i]) - 1);
if (i == 9) history_item[i].flags = FL_MENU_DIVIDER;
else history_item[i].flags = 0;
} else break;
@@ -2005,7 +2004,7 @@ void update_history(const char *flname) {
// Put the new file at the top...
strlcpy(absolute_history[0], absolute, sizeof(absolute_history[0]));
Fl_String fn = fl_filename_shortened(absolute_history[0], 48);
- strncpy(relative_history[0], fn.c_str(), sizeof(relative_history[0]));
+ strncpy(relative_history[0], fn.c_str(), sizeof(relative_history[0]) - 1);
// Update the menu items as needed...
for (i = 0; i < max_files; i ++) {