Fix Crash issue when removing picture in OGG 25/236025/6
authorhj kim <backto.kim@samsung.com>
Fri, 12 Jun 2020 05:23:01 +0000 (14:23 +0900)
committerhj kim <backto.kim@samsung.com>
Wed, 24 Jun 2020 08:55:36 +0000 (17:55 +0900)
XiphComment has removePicture() and it is used for OGG formats such as vorbis ogg or flac ogg.
When try to remove picture on those files we can use this method.
but when remove it with reference from the Picture_list[index], like a FLAC file, crash occurred.
(actually crash not occurred in this method, but after removing, if we try to access (eg. by using save() or getting picture)
the picture list which has more than 1 picture, crash occurred)
I don't know the reason why.
So anyway, modified it to use iterator.

Change-Id: I0dae724860ca3efab42d5e981b7f3fc5adf1d954

src/metadata_editor.cpp

index 22a0115..a64b2b8 100755 (executable)
@@ -1542,7 +1542,9 @@ static int __remove_ogg_picture(Ogg::XiphComment *xtag, int index)
        ret = __is_valid_picture_index(lst.isEmpty(), lst.size(), index);
        metadata_editor_retvm_if(ret != METADATA_EDITOR_ERROR_NONE, ret, "Invalid picture index");
 
-       xtag->removePicture(lst[index], false);
+       TagLib::List<TagLib::FLAC::Picture*>::Iterator it = lst.begin();
+       std::advance(it, index);
+       xtag->removePicture(*it, true);
 
        return METADATA_EDITOR_ERROR_NONE;
 }