When no graph_str had been read from a file, it was duplicated from
avctx->url without checking the result. On allocation failure a NULL was
passed to avfilter_graph_parse_ptr(). Fail with AVERROR(ENOMEM) when the
duplication of a non-NULL url fails, preserving the existing behaviour when
no url is provided.

Signed-off-by: Anas Khan <[email protected]>
---
 libavdevice/lavfi.c | 5 ++++-
 1 file changed, 4 insertions(+), 1 deletion(-)

diff --git a/libavdevice/lavfi.c b/libavdevice/lavfi.c
index 0de2bbdcf8..9e1230cbde 100644
--- a/libavdevice/lavfi.c
+++ b/libavdevice/lavfi.c
@@ -137,8 +137,11 @@ av_cold static int lavfi_read_header(AVFormatContext 
*avctx)
             goto end;
     }
 
-    if (!lavfi->graph_str)
+    if (!lavfi->graph_str) {
         lavfi->graph_str = av_strdup(avctx->url);
+        if (avctx->url && !lavfi->graph_str)
+            FAIL(AVERROR(ENOMEM));
+    }
 
     /* parse the graph, create a stream for each open output */
     if (!(lavfi->graph = avfilter_graph_alloc()))
-- 
2.54.0

_______________________________________________
ffmpeg-devel mailing list -- [email protected]
To unsubscribe send an email to [email protected]

Reply via email to