diff options
author | Clément Bœsch <ubitux@gmail.com> | 2013-04-12 13:01:17 +0200 |
---|---|---|
committer | Clément Bœsch <ubitux@gmail.com> | 2013-04-12 13:01:17 +0200 |
commit | f16a6f667c993a158643b52815ec42961508b0a9 (patch) | |
tree | 7aedbe409f4263fce97e0fb7a2fbf22a1a92e1c1 /libavfilter/vf_libopencv.c | |
parent | 490786c02e8551ab9e7c23d6025a775a6e6a64cc (diff) | |
download | ffmpeg-f16a6f667c993a158643b52815ec42961508b0a9.tar.gz |
lavfi/ocv: fix crash with no dilate arguments.
Diffstat (limited to 'libavfilter/vf_libopencv.c')
-rw-r--r-- | libavfilter/vf_libopencv.c | 13 |
1 files changed, 7 insertions, 6 deletions
diff --git a/libavfilter/vf_libopencv.c b/libavfilter/vf_libopencv.c index b27f30da5f..bd2afa8713 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", |