From 403981a2937742d04988d0891bcb71963372767c Mon Sep 17 00:00:00 2001 From: Albrecht Schlosser Date: Sun, 24 Nov 2024 18:53:40 +0100 Subject: [PATCH] Fix compiler warning (g++ 14) [-Wstringop-overflow] New compiler warning detected by g++ 14.2.0 building with CMake in Release mode. This *temporary* fix suppresses the warning but uses even larger fixed size buffers. Todo: these nasty warnings caused by using fixed buffer sizes should be removed by using std::string in FLTK 1.5.0. --- FL/Fl_Help_View.H | 2 +- src/Fl_Help_View.cxx | 8 ++++---- 2 files changed, 5 insertions(+), 5 deletions(-) diff --git a/FL/Fl_Help_View.H b/FL/Fl_Help_View.H index 2c73926c01..35fd44ee0e 100644 --- a/FL/Fl_Help_View.H +++ b/FL/Fl_Help_View.H @@ -225,7 +225,7 @@ class FL_EXPORT Fl_Help_View : public Fl_Group { // Help viewer widget atargets_; ///< Allocated targets Fl_Help_Target *targets_; ///< Targets - char directory_[FL_PATH_MAX];///< Directory for current file + char directory_[2 * FL_PATH_MAX + 15]; ///< Directory for current file char filename_[FL_PATH_MAX]; ///< Current filename int topline_, ///< Top line in document leftline_, ///< Lefthand position diff --git a/src/Fl_Help_View.cxx b/src/Fl_Help_View.cxx index d77d5caeec..523ef8b59c 100644 --- a/src/Fl_Help_View.cxx +++ b/src/Fl_Help_View.cxx @@ -2701,7 +2701,7 @@ Fl_Shared_Image * Fl_Help_View::get_image(const char *name, int W, int H) { const char *localname; // Local filename char dir[FL_PATH_MAX]; // Current directory - char temp[2 * FL_PATH_MAX], // Temporary filename + char temp[3 * FL_PATH_MAX], // Temporary filename *tempptr; // Pointer into temporary name Fl_Shared_Image *ip; // Image pointer... @@ -2798,8 +2798,8 @@ void Fl_Help_View::follow_link(Fl_Help_Link *linkp) if (strcmp(linkp->filename, filename_) != 0 && linkp->filename[0]) { char dir[FL_PATH_MAX]; // Current directory - char temp[2 * FL_PATH_MAX], // Temporary filename - *tempptr; // Pointer into temporary filename + char temp[3 * FL_PATH_MAX], // Temporary filename + *tempptr; // Pointer into temporary filename if (strchr(directory_, ':') != NULL && @@ -2809,7 +2809,7 @@ void Fl_Help_View::follow_link(Fl_Help_Link *linkp) { strlcpy(temp, directory_, sizeof(temp)); if ((tempptr = strrchr(strchr(directory_, ':') + 3, '/')) != NULL) - strlcpy(tempptr, linkp->filename, sizeof(temp)); + strlcpy(tempptr, linkp->filename, 2 * FL_PATH_MAX); // sizeof(temp)); else strlcat(temp, linkp->filename, sizeof(temp)); }