(add_widget_autopos): don't access to NULL widget.

(del_widget): likewise.

Signed-off-by: Andrew Borodin <aborodin@vmail.ru>
This commit is contained in:
Andrew Borodin 2012-11-28 11:19:02 +04:00
parent 82b1d7bff3
commit 3fc490ea12

View File

@ -858,12 +858,14 @@ unsigned long
add_widget_autopos (WDialog * h, void *w, widget_pos_flags_t pos_flags, const void *before) add_widget_autopos (WDialog * h, void *w, widget_pos_flags_t pos_flags, const void *before)
{ {
Widget *wh = WIDGET (h); Widget *wh = WIDGET (h);
Widget *widget = WIDGET (w); Widget *widget;
/* Don't accept 0 widgets */ /* Don't accept 0 widgets */
if (w == NULL) if (w == NULL)
abort (); abort ();
widget = WIDGET (w);
if ((pos_flags & WPOS_CENTER_HORZ) != 0) if ((pos_flags & WPOS_CENTER_HORZ) != 0)
widget->x = (wh->cols - widget->cols) / 2; widget->x = (wh->cols - widget->cols) / 2;
widget->x += wh->x; widget->x += wh->x;
@ -934,13 +936,15 @@ add_widget_before (WDialog * h, void *w, void *before)
void void
del_widget (void *w) del_widget (void *w)
{ {
WDialog *h = WIDGET (w)->owner; WDialog *h;
GList *d; GList *d;
/* Don't accept NULL widget. This shouldn't happen */ /* Don't accept NULL widget. This shouldn't happen */
if (w == NULL) if (w == NULL)
abort (); abort ();
h = WIDGET (w)->owner;
d = g_list_find (h->widgets, w); d = g_list_find (h->widgets, w);
if (d == h->current) if (d == h->current)
h->current = dlg_widget_next (h, d); h->current = dlg_widget_next (h, d);