lavu/opt: make sure av_opt_set_bin() handles NULL/0.

This commit is contained in:
Nicolas George 2013-03-28 16:45:12 +01:00
parent 9dd54d7422
commit 983d04dd40

View File

@ -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,6 +430,7 @@ int av_opt_set_bin(void *obj, const char *name, const uint8_t *val, int len, int
av_free(*dst);
*dst = ptr;
*lendst = len;
if (len)
memcpy(ptr, val, len);
return 0;