ensure iframe stuff does not de-reference null pointers

svn path=/trunk/netsurf/; revision=10884
This commit is contained in:
Vincent Sanders 2010-10-14 00:59:39 +00:00
parent 7e0e61992a
commit 1dbbbaf64a
2 changed files with 16 additions and 5 deletions

View File

@ -124,7 +124,8 @@ void browser_window_recalculate_iframes(struct browser_window *bw) {
int bw_width, bw_height;
int index;
assert(bw);
assert(bw != NULL);
assert(bw->window != NULL);
/* update window dimensions */
gui_window_get_dimensions(bw->window, &bw_width, &bw_height, false);
@ -137,9 +138,15 @@ void browser_window_recalculate_iframes(struct browser_window *bw) {
for (index = 0; index < bw->iframe_count; index++) {
window = &(bw->iframes[index]);
box_bounds(window->box, &rect);
gui_window_position_frame(window->window, rect.x0, rect.y0,
rect.x1, rect.y1);
if ((window != NULL) && (window->box != NULL)) {
box_bounds(window->box, &rect);
gui_window_position_frame(window->window,
rect.x0, rect.y0,
rect.x1, rect.y1);
} else {
LOG(("Bad IFrame window=%p, box=%p",window,window->box));
}
}
}

View File

@ -2006,6 +2006,8 @@ void gui_window_scroll_visible(struct gui_window *w, int x0, int y0,
void gui_window_position_frame(struct gui_window *w, int x0, int y0,
int x1, int y1)
{
if (w == NULL)
return;
LOG(("position frame %s: %d, %d, %d, %d", w->bw->name,
x0, y0, x1, y1));
MoveWindow(w->drawingarea, x0, y0, x1-x0, y1-y0, true);
@ -2014,9 +2016,11 @@ void gui_window_position_frame(struct gui_window *w, int x0, int y0,
void gui_window_get_dimensions(struct gui_window *w, int *width, int *height,
bool scaled)
{
LOG(("get dimensions %p w=%d h=%d", w, w->width, w->height));
if (w == NULL)
return;
LOG(("get dimensions %p w=%d h=%d", w, w->width, w->height));
*width = w->width;
*height = w->height;
}