adobe-afdko/adobe-afdko-c99-2.patch

38 lines
1.7 KiB
Diff
Raw Normal View History

Author: Sergei Trofimovich <slyich@gmail.com>
Date: Wed Dec 6 20:41:57 2023 +0000
c/shared/source/t1write/t1write.c: fix u8/u16 type mismatch on dereference (gcc-14)
Upcoming `gcc-14` enabled a few warnings into errors, like
`-Wincompatible-pointer-types`. This caused `afdko` build to fail as:
/build/afdko/c/shared/source/t1write/t1write.c: In function saveCstr:
/build/afdko/c/shared/source/t1write/t1write.c:348:28: error: passing argument 3 of writeTmp from incompatible pointer type [-Wincompatible-pointer-types]
348 | if (writeTmp(h, 1, &info->iFD))
| ^~~~~~~~~~
| |
| uint16_t * {aka short unsigned int *}
The code attempts to use only one byte of 16-bit value. The code very
likely is broken on a big-endian system.
The change explicitly truncates 16-bit value down to 8 bit value to
retain existing behaviour on both BE and LE systems.
Submitted upstream: <https://github.com/adobe-type-tools/afdko/pull/1730>
diff --git a/c/public/lib/source/t1write/t1write.c b/c/public/lib/source/t1write/t1write.c
index e16387408a953c07..b2e4c0df27d36e56 100644
--- a/c/public/lib/source/t1write/t1write.c
+++ b/c/public/lib/source/t1write/t1write.c
@@ -345,7 +345,8 @@ static int saveCstr(t1wCtx h, abfGlyphInfo *info,
if (info != NULL && info->flags & ABF_GLYPH_CID &&
!(h->arg.flags & T1W_TYPE_HOST)) {
/* CID-keyed incremental download; write fd index */
- if (writeTmp(h, 1, &info->iFD))
+ unsigned char c = info->iFD;
+ if (writeTmp(h, 1, &c))
return 1;
cstr->length++;
}