[FFmpeg-devel] [PATCH] vf_psnr/ssim: don't crash if stats_file is NULL.
Paul B Mahol
onemda at gmail.com
Fri Oct 23 06:19:13 CEST 2015
Dana 23. 10. 2015. 00:01 osoba "Ronald S. Bultje" <rsbultje at gmail.com>
napisala je:
>
> ---
> libavfilter/vf_psnr.c | 24 +++++++++++++-----------
> libavfilter/vf_ssim.c | 24 +++++++++++++-----------
> 2 files changed, 26 insertions(+), 22 deletions(-)
>
> diff --git a/libavfilter/vf_psnr.c b/libavfilter/vf_psnr.c
> index ca41939..36bbab2 100644
> --- a/libavfilter/vf_psnr.c
> +++ b/libavfilter/vf_psnr.c
> @@ -193,17 +193,19 @@ static av_cold int init(AVFilterContext *ctx)
> s->min_mse = +INFINITY;
> s->max_mse = -INFINITY;
>
> - if (!strcmp(s->stats_file_str, "-")) {
> - s->stats_file = stdout;
> - } else if (s->stats_file_str) {
> - s->stats_file = fopen(s->stats_file_str, "w");
> - if (!s->stats_file) {
> - int err = AVERROR(errno);
> - char buf[128];
> - av_strerror(err, buf, sizeof(buf));
> - av_log(ctx, AV_LOG_ERROR, "Could not open stats file %s:
%s\n",
> - s->stats_file_str, buf);
> - return err;
> + if (s->stats_file_str) {
> + if (!strcmp(s->stats_file_str, "-")) {
> + s->stats_file = stdout;
> + } else {
> + s->stats_file = fopen(s->stats_file_str, "w");
> + if (!s->stats_file) {
> + int err = AVERROR(errno);
> + char buf[128];
> + av_strerror(err, buf, sizeof(buf));
> + av_log(ctx, AV_LOG_ERROR, "Could not open stats file %s:
%s\n",
> + s->stats_file_str, buf);
> + return err;
> + }
> }
> }
>
> diff --git a/libavfilter/vf_ssim.c b/libavfilter/vf_ssim.c
> index 4dc96a7..ce1e3db 100644
> --- a/libavfilter/vf_ssim.c
> +++ b/libavfilter/vf_ssim.c
> @@ -223,17 +223,19 @@ static av_cold int init(AVFilterContext *ctx)
> {
> SSIMContext *s = ctx->priv;
>
> - if (!strcmp(s->stats_file_str, "-")) {
> - s->stats_file = stdout;
> - } else if (s->stats_file_str) {
> - s->stats_file = fopen(s->stats_file_str, "w");
> - if (!s->stats_file) {
> - int err = AVERROR(errno);
> - char buf[128];
> - av_strerror(err, buf, sizeof(buf));
> - av_log(ctx, AV_LOG_ERROR, "Could not open stats file %s:
%s\n",
> - s->stats_file_str, buf);
> - return err;
> + if (s->stats_file_str) {
> + if (!strcmp(s->stats_file_str, "-")) {
> + s->stats_file = stdout;
> + } else {
> + s->stats_file = fopen(s->stats_file_str, "w");
> + if (!s->stats_file) {
> + int err = AVERROR(errno);
> + char buf[128];
> + av_strerror(err, buf, sizeof(buf));
> + av_log(ctx, AV_LOG_ERROR, "Could not open stats file %s:
%s\n",
> + s->stats_file_str, buf);
> + return err;
> + }
> }
> }
>
Ok
> --
> 2.1.2
>
> _______________________________________________
> ffmpeg-devel mailing list
> ffmpeg-devel at ffmpeg.org
> http://ffmpeg.org/mailman/listinfo/ffmpeg-devel
More information about the ffmpeg-devel
mailing list