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:

[...]src/Fl_Help_View.cxx: In member function
  ‘void Fl_Help_View::follow_link(Fl_Help_Link*)’:
[...]src/Fl_Help_View.cxx:2812:18:
  warning: ‘size_t strlcpy(char*, const char*, size_t)’ writing
  4096 bytes into a region of size 2045 overflows the destination
  ... strlcpy(tempptr, linkp->filename, sizeof(temp));
  ...         ~~~~~~~^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
  • Loading branch information
Albrecht Schlosser committed Nov 24, 2024
1 parent d3d0514 commit e06fb7c
Show file tree
Hide file tree
Showing 2 changed files with 3 additions and 3 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
4 changes: 2 additions & 2 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,7 +2798,7 @@ 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
char temp[3 * FL_PATH_MAX], // Temporary filename
*tempptr; // Pointer into temporary filename


Expand Down

0 comments on commit e06fb7c

Please sign in to comment.