Fix runtime errors found by clang's sanitizer (#47082). * src/base/ftobjs.c (FT_Render_Glyph_Internal), src/base/ftoutln.c (FT_Outline_Copy), src/cache/ftcsbits.c (ftc_sbit_copy_bitmap): Properly handle empty input buffer.
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
diff --git a/ChangeLog b/ChangeLog
index a045395..5031a00 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,5 +1,13 @@
2016-02-07 Werner Lemberg <wl@gnu.org>
+ Fix runtime errors found by clang's sanitizer (#47082).
+
+ * src/base/ftobjs.c (FT_Render_Glyph_Internal), src/base/ftoutln.c
+ (FT_Outline_Copy), src/cache/ftcsbits.c (ftc_sbit_copy_bitmap):
+ Properly handle empty input buffer.
+
+2016-02-07 Werner Lemberg <wl@gnu.org>
+
[cff] Minor.
* src/cff/cffgload.c (cff_decoder_parse_charstrings) <cff_op_sqrt>:
@@ -76,7 +84,7 @@
(FT_Face_CheckTrueTypePatents, FT_Face_SetUnpatentedHinting):
Replace code with dummies.
- * src/truetype/ttobjs.c (tt_face_init): Remove now defunct code.
+ * src/truetype/ttobjs.c (tt_face_init): Remove now defunct code.
* src/truetype/ttobjs.h (TT_GraphicsState): Remove `both_x_axis'
field.
diff --git a/src/base/ftobjs.c b/src/base/ftobjs.c
index a68f21b..fa05347 100644
--- a/src/base/ftobjs.c
+++ b/src/base/ftobjs.c
@@ -4201,7 +4201,8 @@
MD5_Init( &ctx );
- MD5_Update( &ctx, bitmap.buffer, rows * pitch );
+ if ( bitmap.buffer )
+ MD5_Update( &ctx, bitmap.buffer, rows * pitch );
MD5_Final( md5, &ctx );
FT_TRACE3(( "MD5 checksum for %dx%d bitmap:\n"
diff --git a/src/base/ftoutln.c b/src/base/ftoutln.c
index 912dfd3..fa2d2cf 100644
--- a/src/base/ftoutln.c
+++ b/src/base/ftoutln.c
@@ -415,11 +415,14 @@
if ( source == target )
return FT_Err_Ok;
- FT_ARRAY_COPY( target->points, source->points, source->n_points );
-
- FT_ARRAY_COPY( target->tags, source->tags, source->n_points );
+ if ( source->n_points )
+ {
+ FT_ARRAY_COPY( target->points, source->points, source->n_points );
+ FT_ARRAY_COPY( target->tags, source->tags, source->n_points );
+ }
- FT_ARRAY_COPY( target->contours, source->contours, source->n_contours );
+ if ( source->n_contours )
+ FT_ARRAY_COPY( target->contours, source->contours, source->n_contours );
/* copy all flags, except the `FT_OUTLINE_OWNER' one */
is_owner = target->flags & FT_OUTLINE_OWNER;
diff --git a/src/cache/ftcsbits.c b/src/cache/ftcsbits.c
index e6b8865..d6f1ddc 100644
--- a/src/cache/ftcsbits.c
+++ b/src/cache/ftcsbits.c
@@ -53,6 +53,8 @@
pitch = -pitch;
size = (FT_ULong)pitch * bitmap->rows;
+ if ( !size )
+ return FT_Err_Ok;
if ( !FT_ALLOC( sbit->buffer, size ) )
FT_MEM_COPY( sbit->buffer, bitmap->buffer, size );