lavu/opt: copy dict in av_opt_copy
authorLukasz Marek <lukasz.m.luki2@gmail.com>
Sat, 8 Nov 2014 17:12:56 +0000 (18:12 +0100)
committerLukasz Marek <lukasz.m.luki2@gmail.com>
Sun, 9 Nov 2014 16:56:08 +0000 (17:56 +0100)
Signed-off-by: Lukasz Marek <lukasz.m.luki2@gmail.com>
libavutil/opt.c

index 6aabfe3..fca5354 100644 (file)
@@ -1595,6 +1595,15 @@ int av_opt_copy(void *dst, void *src)
             *(int*)(field_dst8 + 1) = len;
         } else if (o->type == AV_OPT_TYPE_CONST) {
             // do nothing
+        } else if (o->type == AV_OPT_TYPE_DICT) {
+            AVDictionary **sdict = (AVDictionary **) field_src;
+            AVDictionary **ddict = (AVDictionary **) field_dst;
+            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);
         } else {
             memcpy(field_dst, field_src, opt_size(o->type));
         }