Add basic checks to see if memory was allocated

Make sure the memory was able to be allocated before using it