fixed some malloc error checking for Project1 (A)