wineps.drv: Handle get_bbox failing in calc_ppem_for_height.

Gerald Pfeifer gerald at pfeifer.com
Wed Dec 12 16:13:28 CST 2012


In calc_ppem_for_height, the invocation of get_bbox can fail (in
which case get_bbox returns FALSE and leaves emsize unitialized). 

One way of handling this is to detect this case and have 
calc_ppem_for_height return height, as in the code directly above.

Another one would be just returning 0 or initializing emsize to 0,
which has the same result as returning 0, but that seems less robust?

Gerald

---
 dlls/wineps.drv/download.c | 3 ++-
 1 file changed, 2 insertions(+), 1 deletion(-)

diff --git a/dlls/wineps.drv/download.c b/dlls/wineps.drv/download.c
index 5163cef..7f2378d 100644
--- a/dlls/wineps.drv/download.c
+++ b/dlls/wineps.drv/download.c
@@ -228,7 +228,8 @@ static UINT calc_ppem_for_height(HDC hdc, LONG height)
 
     if(ascent + descent == 0) return height;
 
-    get_bbox(hdc, NULL, &emsize);
+    if(!get_bbox(hdc, NULL, &emsize))
+        return height;
 
     return MulDiv(emsize, height, ascent + descent);
 }
-- 
1.8.0.1



More information about the wine-patches mailing list