freetype-commit
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[freetype2] master 58b61b6: [pcf] Quickly exit if font index < 0.


From: Werner LEMBERG
Subject: [freetype2] master 58b61b6: [pcf] Quickly exit if font index < 0.
Date: Tue, 13 Oct 2015 16:26:44 +0000

branch: master
commit 58b61b6e05597112f8673e5ab9bd175f59e2db5e
Author: Werner Lemberg <address@hidden>
Commit: Werner Lemberg <address@hidden>

    [pcf] Quickly exit if font index < 0.
    
    Similar to other font formats, this commit makes the parser no
    longer check the whole PCF file but only the header and the TOC if
    we just want to get the number of available faces (and a proper
    recognition of the font format).
    
    * src/pcf/pcfdrivr.c (PCF_Face_Init): Updated.
    Exit quickly if face_index < 0.
    
    * src/pcfread.c (pcf_load_font): Add `face_index' argument.
    Exit quickly if face_index < 0.
    
    * src/pcf/pcf.h: Updated.
---
 ChangeLog          |   17 +++++++++++++++++
 src/pcf/pcf.h      |    5 +++--
 src/pcf/pcfdrivr.c |    8 +++++---
 src/pcf/pcfread.c  |   15 ++++++++++-----
 4 files changed, 35 insertions(+), 10 deletions(-)

diff --git a/ChangeLog b/ChangeLog
index b8a99e2..aa5c7b5 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,5 +1,22 @@
 2015-10-13  Werner Lemberg  <address@hidden>
 
+       [pcf] Quickly exit if font index < 0.
+
+       Similar to other font formats, this commit makes the parser no
+       longer check the whole PCF file but only the header and the TOC if
+       we just want to get the number of available faces (and a proper
+       recognition of the font format).
+
+       * src/pcf/pcfdrivr.c (PCF_Face_Init): Updated.
+       Exit quickly if face_index < 0.
+
+       * src/pcfread.c (pcf_load_font): Add `face_index' argument.
+       Exit quickly if face_index < 0.
+
+       * src/pcf/pcf.h: Updated.
+
+2015-10-13  Werner Lemberg  <address@hidden>
+
        [ftfuzzer] Handle TTCs and MM/GX variations.
 
        This patch also contains various other improvements.
diff --git a/src/pcf/pcf.h b/src/pcf/pcf.h
index c0da503..253a33f 100644
--- a/src/pcf/pcf.h
+++ b/src/pcf/pcf.h
@@ -226,8 +226,9 @@ FT_BEGIN_HEADER
 #define GLYPHPADOPTIONS  4 /* I'm not sure about this */
 
   FT_LOCAL( FT_Error )
-  pcf_load_font( FT_Stream,
-                 PCF_Face );
+  pcf_load_font( FT_Stream  stream,
+                 PCF_Face   face,
+                 FT_Long    face_index );
 
 FT_END_HEADER
 
diff --git a/src/pcf/pcfdrivr.c b/src/pcf/pcfdrivr.c
index 8d2ed7c..0f4c518 100644
--- a/src/pcf/pcfdrivr.c
+++ b/src/pcf/pcfdrivr.c
@@ -271,7 +271,7 @@ THE SOFTWARE.
 
     FT_TRACE2(( "PCF driver\n" ));
 
-    error = pcf_load_font( stream, face );
+    error = pcf_load_font( stream, face, face_index );
     if ( error )
     {
       PCF_Face_Done( pcfface );
@@ -332,7 +332,7 @@ THE SOFTWARE.
 
       stream = pcfface->stream;
 
-      error = pcf_load_font( stream, face );
+      error = pcf_load_font( stream, face, face_index );
       if ( error )
         goto Fail;
 
@@ -351,7 +351,9 @@ THE SOFTWARE.
      *      an invalid argument error when the font could be
      *      opened by the specified driver.
      */
-    if ( face_index > 0 && ( face_index & 0xFFFF ) > 0 )
+    if ( face_index < 0 )
+      goto Exit;
+    else if ( face_index > 0 && ( face_index & 0xFFFF ) > 0 )
     {
       FT_ERROR(( "PCF_Face_Init: invalid face index\n" ));
       PCF_Face_Done( pcfface );
diff --git a/src/pcf/pcfread.c b/src/pcf/pcfread.c
index 6a248cf..fca677f 100644
--- a/src/pcf/pcfread.c
+++ b/src/pcf/pcfread.c
@@ -1184,8 +1184,10 @@ THE SOFTWARE.
 
   FT_LOCAL_DEF( FT_Error )
   pcf_load_font( FT_Stream  stream,
-                 PCF_Face   face )
+                 PCF_Face   face,
+                 FT_Long    face_index )
   {
+    FT_Face    root   = FT_FACE( face );
     FT_Error   error;
     FT_Memory  memory = FT_FACE( face )->memory;
     FT_Bool    hasBDFAccelerators;
@@ -1195,6 +1197,13 @@ THE SOFTWARE.
     if ( error )
       goto Exit;
 
+    root->num_faces  = 1;
+    root->face_index = 0;
+
+    /* If we are performing a simple font format check, exit immediately. */
+    if ( face_index < 0 )
+      return FT_Err_Ok;
+
     error = pcf_get_properties( stream, face );
     if ( error )
       goto Exit;
@@ -1237,13 +1246,9 @@ THE SOFTWARE.
 
     /* now construct the face object */
     {
-      FT_Face       root = FT_FACE( face );
       PCF_Property  prop;
 
 
-      root->num_faces  = 1;
-      root->face_index = 0;
-
       root->face_flags |= FT_FACE_FLAG_FIXED_SIZES |
                           FT_FACE_FLAG_HORIZONTAL  |
                           FT_FACE_FLAG_FAST_GLYPHS;



reply via email to

[Prev in Thread] Current Thread [Next in Thread]