shithub: freetype+ttf2subf

Download patch

ref: 8521ad99b03c24040dbc0387966118ebc81f8933
parent: 6df68335f1f64b0d34440b4663822b25094c8f25
author: Werner Lemberg <[email protected]>
date: Tue Aug 16 09:44:38 EDT 2016

[lzw] Optimize last commit.

* src/lzw/ftzopen.c (ft_lzwstate_get_code): Move check into
conditional clause.

git/fs: mount .git/fs: mount/attach disallowed
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,5 +1,12 @@
 2016-08-16  Werner Lemberg  <[email protected]>
 
+	[lzw] Optimize last commit.
+
+	* src/lzw/ftzopen.c (ft_lzwstate_get_code): Move check into
+	conditional clause.
+
+2016-08-16  Werner Lemberg  <[email protected]>
+
 	[lzw] Avoid invalid left shift.
 
 	Reported as
--- a/src/lzw/ftzopen.c
+++ b/src/lzw/ftzopen.c
@@ -65,9 +65,6 @@
     FT_Int    result;
 
 
-    if ( num_bits > LZW_MAX_BITS )
-      return -1;
-
     if ( state->buf_clear                    ||
          offset >= state->buf_size           ||
          state->free_ent >= state->free_bits )
@@ -74,7 +71,10 @@
     {
       if ( state->free_ent >= state->free_bits )
       {
-        state->num_bits  = ++num_bits;
+        state->num_bits = ++num_bits;
+        if ( num_bits > LZW_MAX_BITS )
+          return -1;
+
         state->free_bits = state->num_bits < state->max_bits
                            ? (FT_UInt)( ( 1UL << num_bits ) - 256 )
                            : state->max_free + 1;