[ttgxvar] Avoid "applying zero offset to null pointer"

In C it is undefined behavior to do arithmetic on a null pointer, including
adding zero. When using NotoSansKhmer[wdth,wght].ttf UBSAN produces a report
like

ttgxvar.c:1052:31: runtime error: applying zero offset to null pointer

when adding zero to `varData->deltaSet` (which is null) to produce `bytes`.
Protect against all the potential issues of this kind by returning early if
`varData->regionIdxCount == 0`.

* src/truetype/ttgxvar.c (tt_var_get_item_delta): early return on no regions
This commit is contained in:
Ben Wagner 2024-06-20 15:00:20 -04:00 committed by Alexei Podtelezhnikov
parent 2a7bb4596f
commit b1cbcb2045

View File

@ -1028,6 +1028,9 @@
if ( innerIndex >= varData->itemCount )
return 0; /* Out of range. */
if ( varData->regionIdxCount == 0 )
return 0; /* Avoid "applying zero offset to null pointer". */
if ( varData->regionIdxCount < 16 )
{
deltaSet = deltaSetStack;