static int __remove_ogg_picture(Ogg::XiphComment *xtag, int index)
{
ME_RETVM_IF(!xtag, METADATA_EDITOR_ERROR_INVALID_PARAMETER, "Invalid XiphComment");
- ME_RETV_IF(!__is_valid_index(xtag->pictureList(), index), METADATA_EDITOR_ERROR_INVALID_PARAMETER);
-
- /* xiphComment::removePicture works abnormally. Do not modify this fuction.
- - Use xtag->pictureList()[index] : crashed
- - Use copied xtag->pictureList()[index] : crashed
- - Use iterator with std::next() : heap-use-after-free occured
- */
- List<FLAC::Picture *>::Iterator it = xtag->pictureList().begin();
- std::advance(it, index);
+ auto lst = xtag->pictureList();
+ lst.setAutoDelete(false);
+ ME_RETV_IF(!__is_valid_index(lst, index), METADATA_EDITOR_ERROR_INVALID_PARAMETER);
- /* No need to set it to 'true'. taglib sets auto-delete. */
- xtag->removePicture(*it, false);
+ xtag->removePicture(lst[index], true);
return METADATA_EDITOR_ERROR_NONE;
}
auto lst = __file->pictureList();
ME_RETV_IF(!__is_valid_index(lst, index), METADATA_EDITOR_ERROR_INVALID_PARAMETER);
- /* No need to set it to 'true'. taglib sets auto-delete. */
__file->removePicture(lst[index], false);
return METADATA_EDITOR_ERROR_NONE;
}