[cff] Fix potential bugs in default NDV for CFF2. * src/cff/cffload.c (cff_blend_build_vector): Explicitly build blend vector when `lenNDV' is zero; don't rely on zero-init. Save `lenNDV' as part of cache key even when `lenNDV' is zero.
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
diff --git a/ChangeLog b/ChangeLog
index 86a5818..8035e62 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,5 +1,13 @@
2017-03-17 Dave Arnold <darnold@adobe.com>
+ [cff] Fix potential bugs in default NDV for CFF2.
+
+ * src/cff/cffload.c (cff_blend_build_vector): Explicitly build blend
+ vector when `lenNDV' is zero; don't rely on zero-init.
+ Save `lenNDV' as part of cache key even when `lenNDV' is zero.
+
+2017-03-17 Dave Arnold <darnold@adobe.com>
+
[cff] Fix CFF2 stack allocation.
* src/cff/cffparse.c (cff_parser_init) add 1 for operator.
diff --git a/src/cff/cffload.c b/src/cff/cffload.c
index ed93fb5..91e74f3 100644
--- a/src/cff/cffload.c
+++ b/src/cff/cffload.c
@@ -1463,10 +1463,15 @@
/* Note: `lenNDV' could be zero. */
/* In that case, build default blend vector (1,0,0...). */
- /* In the normal case, initialize each component to 1 */
- /* before inner loop. */
- if ( lenNDV != 0 )
- blend->BV[master] = FT_FIXED_ONE; /* default */
+ if ( !lenNDV )
+ {
+ blend->BV[master] = 0;
+ continue;
+ }
+
+ /* In the normal case, initialize each component to 1 */
+ /* before inner loop. */
+ blend->BV[master] = FT_FIXED_ONE; /* default */
/* inner loop steps through axes in this region */
for ( j = 0; j < lenNDV; j++ )
@@ -1529,12 +1534,12 @@
lenNDV * sizeof ( *NDV ) ) )
goto Exit;
- blend->lenNDV = lenNDV;
FT_MEM_COPY( blend->lastNDV,
NDV,
lenNDV * sizeof ( *NDV ) );
}
+ blend->lenNDV = lenNDV;
blend->builtBV = TRUE;
Exit:
diff --git a/src/cff/cfftypes.h b/src/cff/cfftypes.h
index 8d43e28..74f569f 100644
--- a/src/cff/cfftypes.h
+++ b/src/cff/cfftypes.h
@@ -112,8 +112,8 @@ FT_BEGIN_HEADER
FT_UInt shortDeltaCount; /* not used; always zero */
#endif
- FT_UInt regionIdxCount; /* number of regions in this var data */
- FT_UInt* regionIndices; /* array of `regionCount' indices; */
+ FT_UInt regionIdxCount; /* number of region indexes */
+ FT_UInt* regionIndices; /* array of `regionIdxCount' indices; */
/* these index `varRegionList' */
} CFF_VarData;