mesa: NULL check the pointer before trying to dereference it