diff mbox series

[FFmpeg-devel,4/8] avfilter/aeval: Fix leak of expressions upon reallocation error

Message ID AM7PR03MB6660C07F15FB6046B63C51138FB19@AM7PR03MB6660.eurprd03.prod.outlook.com
State Accepted
Commit 05c1f78a72916ef2466cc5a4fc778810503225ee
Headers show
Series [FFmpeg-devel,1/8] avfilter/vf_w3fdif: Fix segfault on allocation error | expand

Checks

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

Commit Message

Andreas Rheinhardt Oct. 7, 2021, 9:31 a.m. UTC
Fix this by switching to av_dynarray_add_nofree() which is more
natural anyway because the entries of the array are pointers.

Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@outlook.com>
---
 libavfilter/aeval.c | 7 +++----
 1 file changed, 3 insertions(+), 4 deletions(-)
diff mbox series

Patch

diff --git a/libavfilter/aeval.c b/libavfilter/aeval.c
index 2dc8bace51..42cfa81325 100644
--- a/libavfilter/aeval.c
+++ b/libavfilter/aeval.c
@@ -124,11 +124,10 @@  static int parse_channel_expressions(AVFilterContext *ctx,
     }
 
 #define ADD_EXPRESSION(expr_) do {                                      \
-        if (!av_dynarray2_add((void **)&eval->expr, &eval->nb_channels, \
-                              sizeof(*eval->expr), NULL)) {             \
-            ret = AVERROR(ENOMEM);                                      \
+        ret = av_dynarray_add_nofree(&eval->expr,                       \
+                                     &eval->nb_channels, NULL);         \
+        if (ret < 0)                                                    \
             goto end;                                                   \
-        }                                                               \
         eval->expr[eval->nb_channels-1] = NULL;                         \
         ret = av_expr_parse(&eval->expr[eval->nb_channels - 1], expr_,  \
                             var_names, func1_names, func1,              \