Check for error on all malloc() calls