# HG changeset patch # User rubidium # Date 1261419145 0 # Node ID 014650278d9e2e7a09ed9554f433e65dd1c1d862 # Parent 41dee6877371b097aef37d1e422417436faa69c8 (svn r18591) -Fix [FS#3399]: FindScrollbar could trigger an assert if the next widget (in the widget array) was a container-ish (e.g. selection) widget diff --git a/src/widget.cpp b/src/widget.cpp --- a/src/widget.cpp +++ b/src/widget.cpp @@ -1601,7 +1601,11 @@ Scrollbar *NWidgetBackground::FindScrollbar(Window *w, bool allow_next) const { if (this->index >= 0 && allow_next && this->child == NULL && (uint)(this->index) + 1 < w->nested_array_size) { - const NWidgetCore *next_wid = w->GetWidget(this->index + 1); + /* GetWidget ensures that the widget is of the given type. + * As we might have cases where the next widget in the array + * is a non-Core widget (e.g. NWID_SELECTION) we first get + * the base class and then dynamic_cast that. */ + const NWidgetCore *next_wid = dynamic_cast(w->GetWidget(this->index + 1)); if (next_wid != NULL) return next_wid->FindScrollbar(w, false); } return NULL;