summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorJohn Mark Bell <jmb@netsurf-browser.org>2009-11-22 13:28:30 +0000
committerJohn Mark Bell <jmb@netsurf-browser.org>2009-11-22 13:28:30 +0000
commitd010712a9c02ea9df3c340244235911b652c5b3a (patch)
tree3a28c2430fbed91b7507964925f44166cf10f8e4
parent9ca162218376088ea59020327c22e4ac9a099ea1 (diff)
downloadnetsurf-d010712a9c02ea9df3c340244235911b652c5b3a.tar.gz
netsurf-d010712a9c02ea9df3c340244235911b652c5b3a.tar.bz2
Avoid potential NULL pointer dereferences
svn path=/trunk/netsurf/; revision=9680
-rw-r--r--render/layout.c52
1 files changed, 29 insertions, 23 deletions
diff --git a/render/layout.c b/render/layout.c
index f1bf14a78..1b59cebfb 100644
--- a/render/layout.c
+++ b/render/layout.c
@@ -389,32 +389,36 @@ bool layout_block_context(struct box *block, int viewport_height,
layout_block_add_scrollbar(box, BOTTOM);
}
} else if (box->type == BOX_TABLE) {
- enum css_width_e wtype;
- css_fixed width = 0;
- css_unit unit = CSS_UNIT_PX;
-
- wtype = css_computed_width(box->style, &width, &unit);
+ if (box->style != NULL) {
+ enum css_width_e wtype;
+ css_fixed width = 0;
+ css_unit unit = CSS_UNIT_PX;
- if (wtype == CSS_WIDTH_AUTO) {
- /* max available width may be diminished due to
- * floats. */
- int x0, x1, top;
- struct box *left, *right;
- top = cy > y ? cy : y;
- top += max_pos_margin - max_neg_margin;
- x0 = cx;
- x1 = cx + box->parent->width -
+ wtype = css_computed_width(box->style, &width,
+ &unit);
+
+ if (wtype == CSS_WIDTH_AUTO) {
+ /* max available width may be
+ * diminished due to floats. */
+ int x0, x1, top;
+ struct box *left, *right;
+ top = cy > y ? cy : y;
+ top += max_pos_margin - max_neg_margin;
+ x0 = cx;
+ x1 = cx + box->parent->width -
box->parent->padding[LEFT] -
box->parent->padding[RIGHT];
- find_sides(block->float_children, top, top,
- &x0, &x1, &left, &right);
- /* calculate min required left & right margins
- * needed to avoid floats */
- lm = x0 - cx;
- rm = cx + box->parent->width -
+ find_sides(block->float_children,
+ top, top, &x0, &x1,
+ &left, &right);
+ /* calculate min required left & right
+ * margins needed to avoid floats */
+ lm = x0 - cx;
+ rm = cx + box->parent->width -
box->parent->padding[LEFT] -
box->parent->padding[RIGHT] -
x1;
+ }
}
if (!layout_table(box, box->parent->width - lm - rm,
content))
@@ -661,7 +665,8 @@ void layout_minmax_block(struct box *block,
if (block->max_width != UNKNOWN_MAX_WIDTH)
return;
- wtype = css_computed_width(block->style, &width, &wunit);
+ if (block->style != NULL)
+ wtype = css_computed_width(block->style, &width, &wunit);
if (block->gadget && (block->gadget->type == GADGET_TEXTBOX ||
block->gadget->type == GADGET_PASSWORD ||
@@ -880,11 +885,12 @@ bool layout_apply_minmax_height(struct box *box, struct box *container)
bool updated = false;
/* Find containing block for percentage heights */
- if (css_computed_position(box->style) == CSS_POSITION_ABSOLUTE) {
+ if (box->style != NULL && css_computed_position(box->style) ==
+ CSS_POSITION_ABSOLUTE) {
/* Box is absolutely positioned */
assert(container);
containing_block = container;
- } else if (box->float_container &&
+ } else if (box->float_container && box->style != NULL &&
(css_computed_float(box->style) == CSS_FLOAT_LEFT ||
css_computed_float(box->style) == CSS_FLOAT_RIGHT)) {
/* Box is a float */