mirror of
https://github.com/fltk/fltk.git
synced 2026-05-20 12:41:27 +08:00
Avoid crash in Fl::next_window(win)
As documented, Fl::next_window(win) must only be called with a valid *shown* window. The old code would crash if the argument was NULL or the window was not shown. The new code avoids the crash, issues an error message, and returns NULL to the caller.
This commit is contained in:
+6
-1
@@ -659,7 +659,12 @@ Fl_Window* Fl::first_window() {
|
||||
\param[in] window must be shown and not NULL
|
||||
*/
|
||||
Fl_Window* Fl::next_window(const Fl_Window* window) {
|
||||
Fl_X* i = Fl_X::i(window)->next;
|
||||
Fl_X* i = window ? Fl_X::i(window) : 0;
|
||||
if (!i) {
|
||||
Fl::error("Fl::next_window() failed: window (%p) not shown.", window);
|
||||
return 0;
|
||||
}
|
||||
i = i->next;
|
||||
return i ? i->w : 0;
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user