[FFmpeg-devel] [PATCH] vf_psnr/ssim: don't crash if stats_file is NULL.
Ronald S. Bultje
rsbultje at gmail.com
Fri Oct 23 00:00:50 CEST 2015
---
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;
+ }
}
}
--
2.1.2
More information about the ffmpeg-devel
mailing list