Skip to content

Commit

Permalink
Fix compiler warning (g++ 14) [-Wstringop-overflow]
Browse files Browse the repository at this point in the history
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.
  • Loading branch information
Albrecht Schlosser committed Nov 24, 2024
1 parent d3d0514 commit 403981a
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 5 deletions.
2 changes: 1 addition & 1 deletion FL/Fl_Help_View.H
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
8 changes: 4 additions & 4 deletions src/Fl_Help_View.cxx
Original file line number Diff line number Diff line change
Expand Up @@ -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...

Expand Down Expand Up @@ -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 &&
Expand All @@ -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));
}
Expand Down

0 comments on commit 403981a

Please sign in to comment.