diff mbox series

[FFmpeg-devel] avfilter/avfilter: fix OOM case for default activate

Message ID CAPYw7P5xhcC5_asQJkdq5geWDrrkaK5ACSULpHS3dKz2bKF=tA@mail.gmail.com
State New
Headers show
Series [FFmpeg-devel] avfilter/avfilter: fix OOM case for default activate | expand

Checks

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

Commit Message

Paul B Mahol Dec. 1, 2023, 4:06 p.m. UTC
Attached.

Comments

Paul B Mahol Dec. 3, 2023, 3:44 p.m. UTC | #1
Will apply soon.
Nicolas George Dec. 4, 2023, 8:18 a.m. UTC | #2
Paul B Mahol (12023-12-03):
> Will apply soon.

<sigh> Must you really act like an asshole each time? You will wait for
review.
Nicolas George Dec. 6, 2023, 1:13 p.m. UTC | #3
Paul B Mahol (12023-12-01):
> From 2ea2a0df61cbd5519a1c1e88be27a3f8eb883aac Mon Sep 17 00:00:00 2001
> From: Paul B Mahol <onemda@gmail.com>
> Date: Fri, 1 Dec 2023 16:59:07 +0100
> Subject: [PATCH] avfilter/avfilter: fix OOM case for default activate
> 
> Fixes OOM when caller keeps adding frames into filtergraph
> that reached EOF by other means, for example EOF is signalled
> by other filter in filtergraph or by buffersink.
> 
> Signed-off-by: Paul B Mahol <onemda@gmail.com>
> ---
>  libavfilter/avfilter.c | 10 ++++++++++
>  1 file changed, 10 insertions(+)

Looks correct. Good catch.

I am assuming it is enough to fix the issue you wanted to fix by turning
buffersrc to activate. If not, please share the test case you use.
diff mbox series

Patch

From 2ea2a0df61cbd5519a1c1e88be27a3f8eb883aac Mon Sep 17 00:00:00 2001
From: Paul B Mahol <onemda@gmail.com>
Date: Fri, 1 Dec 2023 16:59:07 +0100
Subject: [PATCH] avfilter/avfilter: fix OOM case for default activate

Fixes OOM when caller keeps adding frames into filtergraph
that reached EOF by other means, for example EOF is signalled
by other filter in filtergraph or by buffersink.

Signed-off-by: Paul B Mahol <onemda@gmail.com>
---
 libavfilter/avfilter.c | 10 ++++++++++
 1 file changed, 10 insertions(+)

diff --git a/libavfilter/avfilter.c b/libavfilter/avfilter.c
index ab7782862a..bde1c33d07 100644
--- a/libavfilter/avfilter.c
+++ b/libavfilter/avfilter.c
@@ -1167,6 +1167,16 @@  static int ff_filter_activate_default(AVFilterContext *filter)
 {
     unsigned i;
 
+    for (i = 0; i < filter->nb_outputs; i++) {
+        int ret = filter->outputs[i]->status_in;
+
+        if (ret) {
+            for (int j = 0; j < filter->nb_inputs; j++)
+                ff_inlink_set_status(filter->inputs[j], ret);
+            return 0;
+        }
+    }
+
     for (i = 0; i < filter->nb_inputs; i++) {
         if (samples_ready(filter->inputs[i], filter->inputs[i]->min_samples)) {
             return ff_filter_frame_to_filter(filter->inputs[i]);
-- 
2.42.1