Skip to content

Commit

Permalink
Fixed|libappfw|DialogWidget: Potential null pointer dereference
Browse files Browse the repository at this point in the history
If DialogWidget::buttonWidget() was called with a label string that
is not the dialog, a null pointer dereference would occur. Now an
exception is thrown in this case.
  • Loading branch information
skyjake committed Apr 20, 2014
1 parent 3401f02 commit f3c734e
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 2 deletions.
3 changes: 3 additions & 0 deletions doomsday/libappfw/include/de/widgets/dialogwidget.h
Expand Up @@ -130,6 +130,9 @@ class LIBAPPFW_PUBLIC DialogWidget : public PopupWidget
RoleFlags _role;
};

/// Asked for a label that does not exist in the dialog. @ingroup errors
DENG2_ERROR(UndefinedLabel);

public:
DialogWidget(String const &name = "", Flags const &flags = DefaultFlags);

Expand Down
4 changes: 2 additions & 2 deletions doomsday/libappfw/src/widgets/dialogwidget.cpp
Expand Up @@ -453,9 +453,9 @@ ButtonWidget &DialogWidget::buttonWidget(de::String const &label) const
if(w) return w->as<ButtonWidget>();

w = d->extraButtons->organizer().itemWidget(label);
DENG2_ASSERT(w != 0);
if(w) return w->as<ButtonWidget>();

return w->as<ButtonWidget>();
throw UndefinedLabel("DialogWidget::buttonWidget", "Undefined label \"" + label + "\"");
}

ButtonWidget *DialogWidget::buttonWidget(int roleId) const
Expand Down

0 comments on commit f3c734e

Please sign in to comment.