diff options
| author | Albrecht Schlosser <albrechts.fltk@online.de> | 2022-11-05 19:31:59 +0100 |
|---|---|---|
| committer | Albrecht Schlosser <albrechts.fltk@online.de> | 2022-11-05 19:31:59 +0100 |
| commit | b426a3d7c07c9ffd53141ebd03dcd5e82ff4e52a (patch) | |
| tree | 78dec22c39ad45850d93a7eefcfa5fb8cdb7074b /FL/platform.H | |
| parent | 918395e0916a6ae48663b41173f5c0d887dcc347 (diff) | |
Fix two rare potential bugs (NULL pointer dereferencing)
Both bugs can happen if a widget doesn't have an associated window()
or in similar situations. These fixes returns NULL to prevent crashes.
Bugs observed in special test scenarios, not real-life programs.
Diffstat (limited to 'FL/platform.H')
| -rw-r--r-- | FL/platform.H | 2 |
1 files changed, 1 insertions, 1 deletions
diff --git a/FL/platform.H b/FL/platform.H index fbabca2fb..7dfa4a186 100644 --- a/FL/platform.H +++ b/FL/platform.H @@ -57,7 +57,7 @@ public: Fl_X *next; // static variables, static functions and member functions static Fl_X* first; - static Fl_X* i(const Fl_Window* w) {return (Fl_X*)w->i;} + static Fl_X* i(const Fl_Window* w) {return w ? (Fl_X*)w->i : 0;} # if defined(FLTK_USE_X11) && FLTK_USE_X11 // for backward compatibility static void make_xid(Fl_Window*, XVisualInfo* =fl_visual, Colormap=fl_colormap); static Fl_X* set_xid(Fl_Window*, Window); |
