mirror of
https://github.com/fltk/fltk.git
synced 2026-05-26 18:17:03 +08:00
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.
This commit is contained in:
+1
-1
@@ -57,7 +57,7 @@ public:
|
|||||||
Fl_X *next;
|
Fl_X *next;
|
||||||
// static variables, static functions and member functions
|
// static variables, static functions and member functions
|
||||||
static Fl_X* first;
|
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
|
# if defined(FLTK_USE_X11) && FLTK_USE_X11 // for backward compatibility
|
||||||
static void make_xid(Fl_Window*, XVisualInfo* =fl_visual, Colormap=fl_colormap);
|
static void make_xid(Fl_Window*, XVisualInfo* =fl_visual, Colormap=fl_colormap);
|
||||||
static Fl_X* set_xid(Fl_Window*, Window);
|
static Fl_X* set_xid(Fl_Window*, Window);
|
||||||
|
|||||||
@@ -980,6 +980,7 @@ Fl_X *Fl_Wayland_Window_Driver::makeWindow()
|
|||||||
Fl_Wayland_Screen_Driver::output *output;
|
Fl_Wayland_Screen_Driver::output *output;
|
||||||
wait_for_expose_value = 1;
|
wait_for_expose_value = 1;
|
||||||
|
|
||||||
|
if (pWindow->parent() && !pWindow->window()) return NULL;
|
||||||
if (pWindow->parent() && !pWindow->window()->shown()) return NULL;
|
if (pWindow->parent() && !pWindow->window()->shown()) return NULL;
|
||||||
|
|
||||||
new_window = (struct wld_window *)calloc(1, sizeof *new_window);
|
new_window = (struct wld_window *)calloc(1, sizeof *new_window);
|
||||||
|
|||||||
Reference in New Issue
Block a user