aboutsummaryrefslogtreecommitdiffstats
path: root/libavfilter/vf_libopencv.c
diff options
context:
space:
mode:
authorLuca Barbato <lu_zero@gentoo.org>2015-02-01 02:02:05 +0100
committerVittorio Giovara <vittorio.giovara@gmail.com>2015-02-03 15:23:21 +0000
commita6653787a4b1e89170ff7962312dd110769c83a3 (patch)
tree1a841db28bf1376eb3848ffb7028ee0c926683a5 /libavfilter/vf_libopencv.c
parent9b8c8a9395c849639aea0f6b5300e991e93c3a73 (diff)
downloadffmpeg-a6653787a4b1e89170ff7962312dd110769c83a3.tar.gz
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: libav-stable@libav.org Bug-Id: CID 739878 / CID 739882
Diffstat (limited to 'libavfilter/vf_libopencv.c')
-rw-r--r--libavfilter/vf_libopencv.c18
1 files changed, 12 insertions, 6 deletions
diff --git a/libavfilter/vf_libopencv.c b/libavfilter/vf_libopencv.c
index 31fad1fb24..50d02f84a8 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);