exits the program on memory allocation error