Module: libav
Branch: master
Commit: a6653787a4b1e89170ff7962312dd110769c83a3

Author:    Luca Barbato <[email protected]>
Committer: Vittorio Giovara <[email protected]>
Date:      Sun Feb  1 02:02:05 2015 +0100

libopencv: Check kernel_str life cycle

The string might or might not be set depending if there
are args and in case of error it must be freed nonetheless.

CC: [email protected]
Bug-Id: CID 739878 / CID 739882

---

 libavfilter/vf_libopencv.c |   18 ++++++++++++------
 1 file changed, 12 insertions(+), 6 deletions(-)

diff --git a/libavfilter/vf_libopencv.c b/libavfilter/vf_libopencv.c
index 31fad1f..50d02f8 100644
--- a/libavfilter/vf_libopencv.c
+++ b/libavfilter/vf_libopencv.c
@@ -261,19 +261,25 @@ static av_cold int dilate_init(AVFilterContext *ctx, 
const char *args)
     OCVContext *s = ctx->priv;
     DilateContext *dilate = s->priv;
     char default_kernel_str[] = "3x3+0x0/rect";
-    char *kernel_str;
+    char *kernel_str = NULL;
     const char *buf = args;
     int ret;
 
     dilate->nb_iterations = 1;
 
-    if (args)
+    if (args) {
         kernel_str = av_get_token(&buf, "|");
-    if ((ret = parse_iplconvkernel(&dilate->kernel,
-                                   *kernel_str ? kernel_str : 
default_kernel_str,
-                                   ctx)) < 0)
-        return ret;
+        if (!kernel_str)
+            return AVERROR(ENOMEM);
+    }
+
+    ret = parse_iplconvkernel(&dilate->kernel,
+                              (!kernel_str || !*kernel_str) ? 
default_kernel_str
+                                                            : kernel_str,
+                              ctx);
     av_free(kernel_str);
+    if (ret < 0)
+        return ret;
 
     sscanf(buf, "|%d", &dilate->nb_iterations);
     av_log(ctx, AV_LOG_VERBOSE, "iterations_nb:%d\n", dilate->nb_iterations);

_______________________________________________
libav-commits mailing list
[email protected]
https://lists.libav.org/mailman/listinfo/libav-commits

Reply via email to