diff mbox series

[FFmpeg-devel,34/39] avutil/opt: Check directly for av_dict_copy() failure

Message ID HE1PR0301MB2154A8449AABA33AE32152958F299@HE1PR0301MB2154.eurprd03.prod.outlook.com
State Accepted
Commit 7e03d962a43b33811f6c0f09e72926e7684e96e8
Headers show
Series [FFmpeg-devel,01/39] avcodec/audiotoolboxenc: Remove AV_CODEC_CAP_DR1 | expand

Checks

Context Check Description
andriy/x86_make success Make finished
andriy/x86_make_fate success Make fate finished
andriy/PPC64_make success Make finished
andriy/PPC64_make_fate success Make fate finished

Commit Message

Andreas Rheinhardt May 21, 2021, 9:17 a.m. UTC
av_dict_copy() returned void when this code was written.

Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@outlook.com>
---
Should one add AV_DICT_MULTIKEY to the flags to also copy dictionaries
with multiple entries?

 libavutil/opt.c | 7 ++++---
 1 file changed, 4 insertions(+), 3 deletions(-)
diff mbox series

Patch

diff --git a/libavutil/opt.c b/libavutil/opt.c
index 4124efd9b6..41284d4ecd 100644
--- a/libavutil/opt.c
+++ b/libavutil/opt.c
@@ -1807,12 +1807,13 @@  int av_opt_copy(void *dst, const void *src)
         } else if (o->type == AV_OPT_TYPE_DICT) {
             AVDictionary **sdict = (AVDictionary **) field_src;
             AVDictionary **ddict = (AVDictionary **) field_dst;
+            int ret2;
             if (*sdict != *ddict)
                 av_dict_free(ddict);
             *ddict = NULL;
-            av_dict_copy(ddict, *sdict, 0);
-            if (av_dict_count(*sdict) != av_dict_count(*ddict))
-                ret = AVERROR(ENOMEM);
+            ret2 = av_dict_copy(ddict, *sdict, 0);
+            if (ret2 < 0)
+                ret = ret2;
         } else {
             int size = opt_size(o->type);
             if (size < 0)