diff options
author | Derek Buitenhuis <derek.buitenhuis@gmail.com> | 2016-04-19 19:17:50 +0100 |
---|---|---|
committer | Derek Buitenhuis <derek.buitenhuis@gmail.com> | 2016-04-19 19:19:53 +0100 |
commit | e344646c808c4f2d0e9db32c5c1cbedb5871f171 (patch) | |
tree | e574dae6da6e1689c02851309be549ac82b23f3a /libavutil/opt.c | |
parent | c54d835e2f185f621ea6cda31a9ef5f83e4a4194 (diff) | |
parent | 564b4591bbe223bdc5f36a1131eaef103f23f5d0 (diff) | |
download | ffmpeg-e344646c808c4f2d0e9db32c5c1cbedb5871f171.tar.gz |
Merge commit '564b4591bbe223bdc5f36a1131eaef103f23f5d0'
* commit '564b4591bbe223bdc5f36a1131eaef103f23f5d0':
opt: Add av_opt_copy()
Merged-by: Derek Buitenhuis <derek.buitenhuis@gmail.com>
Diffstat (limited to 'libavutil/opt.c')
-rw-r--r-- | libavutil/opt.c | 12 |
1 files changed, 8 insertions, 4 deletions
diff --git a/libavutil/opt.c b/libavutil/opt.c index eae4f75dcd..cbe36dfd92 100644 --- a/libavutil/opt.c +++ b/libavutil/opt.c @@ -1587,7 +1587,7 @@ static int opt_size(enum AVOptionType type) case AV_OPT_TYPE_SAMPLE_FMT:return sizeof(enum AVSampleFormat); case AV_OPT_TYPE_COLOR: return 4; } - return 0; + return AVERROR(EINVAL); } int av_opt_copy(void *dst, const void *src) @@ -1597,10 +1597,10 @@ int av_opt_copy(void *dst, const void *src) int ret = 0; if (!src) - return 0; + return AVERROR(EINVAL); c = *(AVClass**)src; - if (*(AVClass**)dst && c != *(AVClass**)dst) + if (!c || c != *(AVClass**)dst) return AVERROR(EINVAL); while ((o = av_opt_next(src, o))) { @@ -1637,7 +1637,11 @@ int av_opt_copy(void *dst, const void *src) if (av_dict_count(*sdict) != av_dict_count(*ddict)) ret = AVERROR(ENOMEM); } else { - memcpy(field_dst, field_src, opt_size(o->type)); + int size = opt_size(o->type); + if (size < 0) + ret = size; + else + memcpy(field_dst, field_src, size); } } return ret; |