diff mbox series

[FFmpeg-devel,12/17] lavu/opt: avoid accidentally propagating spurious errors

Message ID 20240926161901.31421-2-anton@khirnov.net
State New
Headers show
Series [FFmpeg-devel,01/10] fftools/ffmpeg_filter: stop using avfilter_graph_alloc_filter() incorrectly | expand

Checks

Context Check Description
andriy/make_x86 success Make finished
andriy/make_fate_x86 success Make fate finished

Commit Message

Anton Khirnov Sept. 26, 2024, 4:18 p.m. UTC
An error from read_number() is non-fatal here and should not be
forwarded.
---
 libavutil/opt.c | 6 ++++--
 1 file changed, 4 insertions(+), 2 deletions(-)

Comments

Anton Khirnov Sept. 28, 2024, 3:16 p.m. UTC | #1
Pushed the set up to this patch, will wait a few more days for the rest
in case someone wants to comment on the API changes.
diff mbox series

Patch

diff --git a/libavutil/opt.c b/libavutil/opt.c
index 02ed9d9fe9..93f2bb1320 100644
--- a/libavutil/opt.c
+++ b/libavutil/opt.c
@@ -2343,13 +2343,15 @@  int av_opt_set_array(void *obj, const char *name, int search_flags,
         int64_t intnum = 1;
 
         if (val_type == TYPE_BASE(o->type)) {
+            int err;
+
             ret = opt_copy_elem(obj, val_type, dst, src);
             if (ret < 0)
                 goto fail;
 
             // validate the range for numeric options
-            ret = read_number(o, dst, &num, &den, &intnum);
-            if (ret >= 0 && TYPE_BASE(o->type) != AV_OPT_TYPE_FLAGS &&
+            err = read_number(o, dst, &num, &den, &intnum);
+            if (err >= 0 && TYPE_BASE(o->type) != AV_OPT_TYPE_FLAGS &&
                 (!den || o->max * den < num * intnum || o->min * den > num * intnum)) {
                 num = den ? num * intnum / den : (num && intnum ? INFINITY : NAN);
                 av_log(obj, AV_LOG_ERROR, "Cannot set array element %u for "