summaryrefslogtreecommitdiff
path: root/libavutil/opt.c
diff options
context:
space:
mode:
authorNicolas George <nicolas.george@normalesup.org>2013-03-28 16:45:12 +0100
committerNicolas George <nicolas.george@normalesup.org>2013-04-01 10:38:38 +0200
commit983d04dd40a40d2d099d9c382e84da49fd2fe031 (patch)
tree365a26dc254a9b2a03ccc59599aa434e494dc234 /libavutil/opt.c
parent9dd54d74226eaaa1087ba994ba212bf9a107c97d (diff)
downloadffmpeg-983d04dd40a40d2d099d9c382e84da49fd2fe031.tar.gz
lavu/opt: make sure av_opt_set_bin() handles NULL/0.
Diffstat (limited to 'libavutil/opt.c')
-rw-r--r--libavutil/opt.c7
1 files changed, 4 insertions, 3 deletions
diff --git a/libavutil/opt.c b/libavutil/opt.c
index fb3b724bd6..ab73913a39 100644
--- a/libavutil/opt.c
+++ b/libavutil/opt.c
@@ -420,8 +420,8 @@ int av_opt_set_bin(void *obj, const char *name, const uint8_t *val, int len, int
if (o->type != AV_OPT_TYPE_BINARY)
return AVERROR(EINVAL);
- ptr = av_malloc(len);
- if (!ptr)
+ ptr = len ? av_malloc(len) : NULL;
+ if (len && !ptr)
return AVERROR(ENOMEM);
dst = (uint8_t **)(((uint8_t *)target_obj) + o->offset);
@@ -430,7 +430,8 @@ int av_opt_set_bin(void *obj, const char *name, const uint8_t *val, int len, int
av_free(*dst);
*dst = ptr;
*lendst = len;
- memcpy(ptr, val, len);
+ if (len)
+ memcpy(ptr, val, len);
return 0;
}