]> git.sesse.net Git - ffmpeg/commitdiff
libavcodec/avpacket: Don't simply forward return value of av_dict_set()
authorAndreas Rheinhardt <andreas.rheinhardt@gmail.com>
Fri, 17 Apr 2020 13:55:57 +0000 (15:55 +0200)
committerAndreas Rheinhardt <andreas.rheinhardt@gmail.com>
Thu, 23 Apr 2020 17:42:03 +0000 (19:42 +0200)
The documentation of av_dict_set() states that values >= 0 indicate
success, whereas av_packet_unpack_dictionary() implies that return
values > 0 are impossible. So only forward the return value of
av_dict_set() in av_packet_unpack_dictionary() on error.

(Btw: av_dict_set() does currently not return values > 0.)

Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@gmail.com>
libavcodec/avpacket.c

index 1b53451359de47a60c7a7e49172736c2119d9d12..55b509108eb6c98a7f01f054e2dcce34d429e014 100644 (file)
@@ -526,10 +526,10 @@ fail:
 int av_packet_unpack_dictionary(const uint8_t *data, int size, AVDictionary **dict)
 {
     const uint8_t *end;
-    int ret = 0;
+    int ret;
 
     if (!dict || !data || !size)
-        return ret;
+        return 0;
     end = data + size;
     if (size && end[-1])
         return AVERROR_INVALIDDATA;
@@ -542,11 +542,11 @@ int av_packet_unpack_dictionary(const uint8_t *data, int size, AVDictionary **di
 
         ret = av_dict_set(dict, key, val, 0);
         if (ret < 0)
-            break;
+            return ret;
         data = val + strlen(val) + 1;
     }
 
-    return ret;
+    return 0;
 }
 
 int av_packet_shrink_side_data(AVPacket *pkt, enum AVPacketSideDataType type,