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:
parent
930013638b
commit
c12408b53f
@ -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;
|
||||
}
|
||||
|
||||
|
Loading…
x
Reference in New Issue
Block a user