[FFmpeg-cvslog] lavfi/ocv: fix crash with no dilate arguments.
Clément Bœsch
git at videolan.org
Fri Apr 12 13:01:29 CEST 2013
ffmpeg | branch: master | Clément Bœsch <ubitux at gmail.com> | Fri Apr 12 13:01:17 2013 +0200| [f16a6f667c993a158643b52815ec42961508b0a9] | committer: Clément Bœsch
lavfi/ocv: fix crash with no dilate arguments.
> http://git.videolan.org/gitweb.cgi/ffmpeg.git/?a=commit;h=f16a6f667c993a158643b52815ec42961508b0a9
---
libavfilter/vf_libopencv.c | 13 +++++++------
1 file changed, 7 insertions(+), 6 deletions(-)
diff --git a/libavfilter/vf_libopencv.c b/libavfilter/vf_libopencv.c
index b27f30d..bd2afa8 100644
--- a/libavfilter/vf_libopencv.c
+++ b/libavfilter/vf_libopencv.c
@@ -261,17 +261,18 @@ static av_cold int dilate_init(AVFilterContext *ctx, const char *args)
const char *buf = args;
int ret;
- dilate->nb_iterations = 1;
-
if (args)
kernel_str = av_get_token(&buf, "|");
- if ((ret = parse_iplconvkernel(&dilate->kernel,
- *kernel_str ? kernel_str : default_kernel_str,
- ctx)) < 0)
+ else
+ kernel_str = av_strdup(default_kernel_str);
+ if (!kernel_str)
+ return AVERROR(ENOMEM);
+ if ((ret = parse_iplconvkernel(&dilate->kernel, kernel_str, ctx)) < 0)
return ret;
av_free(kernel_str);
- sscanf(buf, "|%d", &dilate->nb_iterations);
+ if (!buf || sscanf(buf, "|%d", &dilate->nb_iterations) != 1)
+ dilate->nb_iterations = 1;
av_log(ctx, AV_LOG_VERBOSE, "iterations_nb:%d\n", dilate->nb_iterations);
if (dilate->nb_iterations <= 0) {
av_log(ctx, AV_LOG_ERROR, "Invalid non-positive value '%d' for nb_iterations\n",
More information about the ffmpeg-cvslog
mailing list