src/mathutils.c: return NULL on error