]> git.sesse.net Git - ffmpeg/commitdiff
avutil/frame: fix remove_side_data
authorZhao Zhili <quinkblack@foxmail.com>
Sat, 2 Nov 2019 17:41:18 +0000 (01:41 +0800)
committerMarton Balint <cus@passwd.hu>
Mon, 11 Nov 2019 21:15:45 +0000 (22:15 +0100)
remove_side_data is supposed to remove a single instance by design.
Since new_side_data() doesn't forbid add multiple instances of the
same type, remove_side_data should deal with that.

Signed-off-by: Marton Balint <cus@passwd.hu>
libavutil/frame.c
libavutil/frame.h

index dcf1fc3d17b5366596b19a35b82ab6b52d636eee..e4038096c2c8800a25949f4ee2dd597222e64ae3 100644 (file)
@@ -806,7 +806,7 @@ void av_frame_remove_side_data(AVFrame *frame, enum AVFrameSideDataType type)
 {
     int i;
 
-    for (i = 0; i < frame->nb_side_data; i++) {
+    for (i = frame->nb_side_data - 1; i >= 0; i--) {
         AVFrameSideData *sd = frame->side_data[i];
         if (sd->type == type) {
             free_side_data(&frame->side_data[i]);
index 5d3231e7bb68975266e1637f124bb7a284524444..b5afb58634d6a403398705640d23562b35bd178c 100644 (file)
@@ -920,8 +920,7 @@ AVFrameSideData *av_frame_get_side_data(const AVFrame *frame,
                                         enum AVFrameSideDataType type);
 
 /**
- * If side data of the supplied type exists in the frame, free it and remove it
- * from the frame.
+ * Remove and free all side data instances of the given type.
  */
 void av_frame_remove_side_data(AVFrame *frame, enum AVFrameSideDataType type);