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);
- auto it = std::next(xtag->pictureList().begin(), index);
+ /* 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);
+
/* No need to set it to 'true'. taglib sets auto-delete. */
xtag->removePicture(*it, false);