Fix to free ptr->data