textbox: fix integer overflow

Signed-off-by: Julien Danjou <julien@danjou.info>
This commit is contained in:
Julien Danjou 2009-08-27 15:34:05 +02:00
parent 69999fee93
commit 34967f7b13
1 changed files with 12 additions and 2 deletions

View File

@ -178,8 +178,18 @@ textbox_draw(widget_t *widget, draw_context_t *ctx, area_t geometry, wibox_t *p)
geometry.x += d->margin.left; geometry.x += d->margin.left;
geometry.y += d->margin.top; geometry.y += d->margin.top;
int margin_width = d->margin.left + d->margin.right;
if(margin_width <= geometry.width)
geometry.width -= d->margin.left + d->margin.right; geometry.width -= d->margin.left + d->margin.right;
else
geometry.width = 0;
int margin_height = d->margin.top + d->margin.bottom;
if(margin_height <= geometry.height)
geometry.height -= d->margin.top + d->margin.bottom; geometry.height -= d->margin.top + d->margin.bottom;
else
geometry.height = 0;
draw_text(ctx, &d->data, d->ellip, d->wrap, d->align, d->valign, geometry, &d->extents); draw_text(ctx, &d->data, d->ellip, d->wrap, d->align, d->valign, geometry, &d->extents);
} }