Fix ubsan null pointer passed as argument 2