From 34967f7b13e257ce43e165e25fab739923c36290 Mon Sep 17 00:00:00 2001 From: Julien Danjou Date: Thu, 27 Aug 2009 15:34:05 +0200 Subject: [PATCH] textbox: fix integer overflow Signed-off-by: Julien Danjou --- widgets/textbox.c | 14 ++++++++++++-- 1 file changed, 12 insertions(+), 2 deletions(-) diff --git a/widgets/textbox.c b/widgets/textbox.c index 5ce8c20ca..af88c612d 100644 --- a/widgets/textbox.c +++ b/widgets/textbox.c @@ -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.y += d->margin.top; - geometry.width -= d->margin.left + d->margin.right; - geometry.height -= d->margin.top + d->margin.bottom; + + int margin_width = d->margin.left + d->margin.right; + if(margin_width <= geometry.width) + 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; + else + geometry.height = 0; draw_text(ctx, &d->data, d->ellip, d->wrap, d->align, d->valign, geometry, &d->extents); }