From e23e9a06426e80e98fe2021a9a3326f9eea31d15 Mon Sep 17 00:00:00 2001 From: Ben Pfaff Date: Thu, 4 Feb 2010 20:21:47 -0800 Subject: [PATCH] cairo: Require minimum page width. A too-narrow page (in particular, a zero-width page) can cause an infinite loop in the rendering code. --- src/output/cairo.c | 14 ++++++++++++-- 1 file changed, 12 insertions(+), 2 deletions(-) diff --git a/src/output/cairo.c b/src/output/cairo.c index ba94cc53..94dafd88 100644 --- a/src/output/cairo.c +++ b/src/output/cairo.c @@ -1,5 +1,5 @@ /* PSPP - a program for statistical analysis. - Copyright (C) 2009 Free Software Foundation, Inc. + Copyright (C) 2009, 2010 Free Software Foundation, Inc. This program is free software: you can redistribute it and/or modify it under the terms of the GNU General Public License as published by @@ -235,7 +235,7 @@ static struct output_driver * xr_create (const char *name, enum output_device_type device_type, struct string_map *o) { - enum { MIN_LENGTH = 3 }; + enum { MIN_WIDTH = 3, MIN_LENGTH = 3 }; struct output_driver *d; struct xr_driver *xr; cairo_surface_t *surface; @@ -300,6 +300,16 @@ xr_create (const char *name, enum output_device_type device_type, if (!xr_set_cairo (xr, xr->cairo)) goto error; + if (xr->width / (xr->font_height / 2) < MIN_WIDTH) + { + error (0, 0, _("The defined page is not wide enough to hold at least %d " + "characters in the default font. In fact, there's only " + "room for %d characters."), + MIN_WIDTH, + xr->width / (xr->font_height / 2)); + goto error; + } + if (xr->length / xr->font_height < MIN_LENGTH) { error (0, 0, _("The defined page is not long " -- 2.30.2