Previously you couldn't set them back to NULL, only to a zero-length
string. Now it's only disallowed to pass NULL when setting numeric
options.
---
libavutil/opt.c | 11 +++++++----
1 file changed, 7 insertions(+), 4 deletions(-)
diff --git a/libavutil/opt.c b/libavutil/opt.c
index f2b9473..6897a30 100644
--- a/libavutil/opt.c
+++ b/libavutil/opt.c
@@ -108,10 +108,12 @@ static int set_string_binary(void *obj, const AVOption
*o, const char *val, uint
{
int *lendst = (int *)(dst + 1);
uint8_t *bin, *ptr;
- int len = strlen(val);
+ int len = val ? strlen(val) : 0;
av_freep(dst);
*lendst = 0;
+ if (!val)
+ return 0;
if (len & 1)
return AVERROR(EINVAL);
@@ -136,7 +138,8 @@ static int set_string_binary(void *obj, const AVOption *o,
const char *val, uint
static int set_string(void *obj, const AVOption *o, const char *val, uint8_t
**dst)
{
av_freep(dst);
- *dst = av_strdup(val);
+ if (val)
+ *dst = av_strdup(val);
return 0;
}
@@ -149,6 +152,8 @@ static int set_string(void *obj, const AVOption *o, const
char *val, uint8_t **d
static int set_string_number(void *obj, void *target_obj, const AVOption *o,
const char *val, void *dst)
{
int ret = 0, notfirst = 0;
+ if (!val)
+ return AVERROR(EINVAL);
for (;;) {
int i, den = 1;
char buf[256];
@@ -212,8 +217,6 @@ int av_opt_set(void *obj, const char *name, const char
*val, int search_flags)
const AVOption *o = av_opt_find2(obj, name, NULL, 0, search_flags,
&target_obj);
if (!o || !target_obj)
return AVERROR_OPTION_NOT_FOUND;
- if (!val)
- return AVERROR(EINVAL);
dst = ((uint8_t*)target_obj) + o->offset;
switch (o->type) {
--
1.7.9.4
_______________________________________________
libav-devel mailing list
[email protected]
https://lists.libav.org/mailman/listinfo/libav-devel