Skip to content

[truetype] Fix undefined behaviour in ttgxvar

mlugg1 requested to merge mlugg1/freetype:fix/ub-ttgxvar into master

There's a really weird piece of undefined behaviour in C: offsetting from a null pointer, in any capacity (even adding 0), is UB. ttgxvar.c in a few places relies on the fact that NULL + 0 == NULL, but this trips UBSan when it's in use. Here I just added a few conditionals so that if the length in question is 0, the pointer arithmetic (and the following loop) is never run - this will of course still perform the addition if you have a NULL ptr with a nonzero length, but that would be a major bug anyway so a crash is probably a good thing in that case.

Edited by mlugg1

Merge request reports