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

pull/13/merge
Nicolas George 12 years ago
parent 9dd54d7422
commit 983d04dd40
  1. 7
      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) if (o->type != AV_OPT_TYPE_BINARY)
return AVERROR(EINVAL); return AVERROR(EINVAL);
ptr = av_malloc(len); ptr = len ? av_malloc(len) : NULL;
if (!ptr) if (len && !ptr)
return AVERROR(ENOMEM); return AVERROR(ENOMEM);
dst = (uint8_t **)(((uint8_t *)target_obj) + o->offset); 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); av_free(*dst);
*dst = ptr; *dst = ptr;
*lendst = len; *lendst = len;
memcpy(ptr, val, len); if (len)
memcpy(ptr, val, len);
return 0; return 0;
} }

Loading…
Cancel
Save