set ptr to nil after free