[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[freetype2] div-by-zero e66480b56: * src/base/ftobjs.c (FT_Request_Metri
From: |
Werner Lemberg |
Subject: |
[freetype2] div-by-zero e66480b56: * src/base/ftobjs.c (FT_Request_Metrics): Avoid division by zero. |
Date: |
Tue, 3 Jan 2023 15:41:52 -0500 (EST) |
branch: div-by-zero
commit e66480b56f9e09ded9a355dc1a9c109d8c6e3571
Author: Alexei Podtelezhnikov <apodtele@gmail.com>
Commit: Alexei Podtelezhnikov <apodtele@gmail.com>
* src/base/ftobjs.c (FT_Request_Metrics): Avoid division by zero.
The division-by-zero might happen in broken fonts (see #1194).
Instead of returning a huge number from FT_DivFix until and failing
to scale later, we now bail immediately.
---
src/base/ftobjs.c | 8 ++++++++
1 file changed, 8 insertions(+)
diff --git a/src/base/ftobjs.c b/src/base/ftobjs.c
index 7f1f063cc..8b99a2088 100644
--- a/src/base/ftobjs.c
+++ b/src/base/ftobjs.c
@@ -3276,6 +3276,14 @@
if ( h < 0 )
h = -h;
+ if ( ( !w && req->width ) ||
+ ( !h && ( req->height || !req->width ) ) )
+ {
+ FT_ERROR(( "FT_Request_Metrics: Divide by zero\n" ));
+ error = FT_ERR( Divide_By_Zero );
+ goto Exit;
+ }
+
scaled_w = FT_REQUEST_WIDTH ( req );
scaled_h = FT_REQUEST_HEIGHT( req );
[Prev in Thread] |
Current Thread |
[Next in Thread] |
- [freetype2] div-by-zero e66480b56: * src/base/ftobjs.c (FT_Request_Metrics): Avoid division by zero.,
Werner Lemberg <=