Various clang 8.0 static analyzer fixes. Reported by Sender Ghost <lightside@gmx.com>. * src/autofit/afcjk.c (af_cjk_hints_compute_edges): Catch a corner case where `edge->first' could be NULL. * src/pfr/pfrobjs.c (pfr_slot_load): Remove unnecessary test of `size'. * src/raster/ftraster.c (Draw_Sweep): Catch a corner case where `draw_right' might be NULL. * src/sfnt/ttmtx.c (tt_face_get_metrics): Fix limit test for `aadvance'. Ensure `abearing' always hold a meaningful result. * src/truetype/ttgload.c (load_truetype_glyph): Ensure `subglyph' is not NULL before accessing it. * src/truetype/ttgxvar.c (TT_Set_Named_Instance): Remove unnecessary test of `namedstyle'. * src/type42/t42parse.c (t42_parser_done): Ensure `parser->root.funcs.done' is not NULL before accessing it.
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170
diff --git a/ChangeLog b/ChangeLog
index 56db60a..9f26035 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,30 @@
+2019-05-04 Werner Lemberg <wl@gnu.org>
+
+ Various clang 8.0 static analyzer fixes.
+
+ Reported by Sender Ghost <lightside@gmx.com>.
+
+ * src/autofit/afcjk.c (af_cjk_hints_compute_edges): Catch a corner
+ case where `edge->first' could be NULL.
+
+ * src/pfr/pfrobjs.c (pfr_slot_load): Remove unnecessary test of
+ `size'.
+
+ * src/raster/ftraster.c (Draw_Sweep): Catch a corner case where
+ `draw_right' might be NULL.
+
+ * src/sfnt/ttmtx.c (tt_face_get_metrics): Fix limit test for
+ `aadvance'.
+ Ensure `abearing' always hold a meaningful result.
+
+ * src/truetype/ttgload.c (load_truetype_glyph): Ensure `subglyph' is
+ not NULL before accessing it.
+ * src/truetype/ttgxvar.c (TT_Set_Named_Instance): Remove unnecessary
+ test of `namedstyle'.
+
+ * src/type42/t42parse.c (t42_parser_done): Ensure
+ `parser->root.funcs.done' is not NULL before accessing it.
+
2019-05-03 Alexei Podtelezhnikov <apodtele@gmail.com>
Miscellaneous macro updates.
diff --git a/src/autofit/afcjk.c b/src/autofit/afcjk.c
index 3b2b1cf..a61689b 100644
--- a/src/autofit/afcjk.c
+++ b/src/autofit/afcjk.c
@@ -1184,6 +1184,8 @@
seg = edge->first;
+ if ( !seg )
+ goto Skip_Loop;
do
{
@@ -1239,13 +1241,14 @@
edge2->flags |= AF_EDGE_SERIF;
}
else
- edge->link = edge2;
+ edge->link = edge2;
}
seg = seg->edge_next;
} while ( seg != edge->first );
+ Skip_Loop:
/* set the round/straight flags */
edge->flags = AF_EDGE_NORMAL;
diff --git a/src/cache/rules.mk b/src/cache/rules.mk
index abcb242..1618d98 100644
--- a/src/cache/rules.mk
+++ b/src/cache/rules.mk
@@ -15,7 +15,7 @@
# Cache driver directory
#
-CACHE_DIR := $(SRC_DIR)/cache
+CACHE_DIR := $(SRC_DIR)/cache
# compilation flags for the driver
diff --git a/src/pfr/pfrobjs.c b/src/pfr/pfrobjs.c
index e103a3f..9765f95 100644
--- a/src/pfr/pfrobjs.c
+++ b/src/pfr/pfrobjs.c
@@ -378,7 +378,7 @@
outline->flags &= ~FT_OUTLINE_OWNER;
outline->flags |= FT_OUTLINE_REVERSE_FILL;
- if ( size && pfrsize->metrics.y_ppem < 24 )
+ if ( pfrsize->metrics.y_ppem < 24 )
outline->flags |= FT_OUTLINE_HIGH_PRECISION;
/* compute the advance vector */
diff --git a/src/raster/ftraster.c b/src/raster/ftraster.c
index 2859113..e842175 100644
--- a/src/raster/ftraster.c
+++ b/src/raster/ftraster.c
@@ -2778,6 +2778,12 @@
Sort( &draw_left );
Sort( &draw_right );
+ if ( !draw_right )
+ {
+ ras.error = FT_THROW( Invalid );
+ return FAILURE;
+ }
+
y_change = (Short)ras.sizeBuff[-ras.numTurns--];
y_height = (Short)( y_change - y );
diff --git a/src/sfnt/ttmtx.c b/src/sfnt/ttmtx.c
index 7a4d2be..b6725c9 100644
--- a/src/sfnt/ttmtx.c
+++ b/src/sfnt/ttmtx.c
@@ -280,7 +280,7 @@
else
{
table_pos += 4 * ( k - 1 );
- if ( table_pos + 4 > table_end )
+ if ( table_pos + 2 > table_end )
goto NoData;
if ( FT_STREAM_SEEK( table_pos ) ||
@@ -292,7 +292,9 @@
*abearing = 0;
else
{
- if ( !FT_STREAM_SEEK( table_pos ) )
+ if ( FT_STREAM_SEEK( table_pos ) )
+ *abearing = 0;
+ else
(void)FT_READ_SHORT( *abearing );
}
}
diff --git a/src/truetype/ttgload.c b/src/truetype/ttgload.c
index cbee27a..501ddc7 100644
--- a/src/truetype/ttgload.c
+++ b/src/truetype/ttgload.c
@@ -2088,6 +2088,7 @@
loader->ins_pos = ins_pos;
if ( IS_HINTED( loader->load_flags ) &&
#ifdef TT_USE_BYTECODE_INTERPRETER
+ subglyph &&
subglyph->flags & WE_HAVE_INSTR &&
#endif
num_points > start_point )
diff --git a/src/truetype/ttgxvar.c b/src/truetype/ttgxvar.c
index 6854d23..0b015b5 100644
--- a/src/truetype/ttgxvar.c
+++ b/src/truetype/ttgxvar.c
@@ -3054,7 +3054,7 @@
if ( instance_index > num_instances )
goto Exit;
- if ( instance_index > 0 && mmvar->namedstyle )
+ if ( instance_index > 0 )
{
FT_Memory memory = face->root.memory;
SFNT_Service sfnt = (SFNT_Service)face->sfnt;
diff --git a/src/type42/t42parse.c b/src/type42/t42parse.c
index b653a13..a4aefcf 100644
--- a/src/type42/t42parse.c
+++ b/src/type42/t42parse.c
@@ -226,7 +226,8 @@
if ( !parser->in_memory )
FT_FREE( parser->base_dict );
- parser->root.funcs.done( &parser->root );
+ if ( parser->root.funcs.done )
+ parser->root.funcs.done( &parser->root );
}