freeing the data pointer and returning error flags