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.
This commit is contained in:
Albrecht Schlosser 2024-11-24 18:53:40 +01:00
parent d3d051483a
commit 403981a293
2 changed files with 5 additions and 5 deletions

View File

@ -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

View File

@ -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));
}