Update mmm.c

Add check for memory allocation failure.