mmg: test for nullptr before dereferencing the pointer