From 6dd9108c5865c1ea2ab0e834f4ae85aa279bcca9 Mon Sep 17 00:00:00 2001 From: Robin Watts Date: Fri, 6 Jan 2012 14:42:25 +0000 Subject: Various fixes to avoid arithmetic problems. Various fixes to avoid overflow problems, division by zeros, use of uninitialised variables etc. All from/suggested by Zenikos patch. --- pdf/pdf_annot.c | 10 ++++++++-- 1 file changed, 8 insertions(+), 2 deletions(-) (limited to 'pdf') diff --git a/pdf/pdf_annot.c b/pdf/pdf_annot.c index 228a214e..f7e7f081 100644 --- a/pdf/pdf_annot.c +++ b/pdf/pdf_annot.c @@ -328,8 +328,14 @@ pdf_transform_annot(pdf_annot *annot) float w, h, x, y; bbox = fz_transform_rect(matrix, bbox); - w = (rect.x1 - rect.x0) / (bbox.x1 - bbox.x0); - h = (rect.y1 - rect.y0) / (bbox.y1 - bbox.y0); + if (bbox.x1 == bbox.x0) + w = 0; + else + w = (rect.x1 - rect.x0) / (bbox.x1 - bbox.x0); + if (bbox.y1 == bbox.y0) + h = 0; + else + h = (rect.y1 - rect.y0) / (bbox.y1 - bbox.y0); x = rect.x0 - bbox.x0; y = rect.y0 - bbox.y0; -- cgit v1.2.3