[FFmpeg-devel] [PATCH] ffmpeg: check fclose return values

Ganesh Ajjanagadde gajjanagadde at gmail.com
Thu Jan 7 06:00:46 CET 2016


In the spirit of commit a956840cbc. Simple method to reproduce:
pass -vstats_file /dev/full to ffmpeg.

All raw fclose usages in ffmpeg.c taken care of here.

Signed-off-by: Ganesh Ajjanagadde <gajjanagadde at gmail.com>
---
 ffmpeg.c | 13 ++++++++++---
 1 file changed, 10 insertions(+), 3 deletions(-)

diff --git a/ffmpeg.c b/ffmpeg.c
index 0c83165..858e6d7 100644
--- a/ffmpeg.c
+++ b/ffmpeg.c
@@ -554,8 +554,12 @@ static void ffmpeg_cleanup(int ret)
         av_freep(&input_streams[i]);
     }
 
-    if (vstats_file)
-        fclose(vstats_file);
+    if (vstats_file) {
+        if ((ret = fclose(vstats_file)) < 0)
+            av_log(NULL, AV_LOG_ERROR,
+                   "Error closing vstats file, loss of information possible: %s\n",
+                   av_err2str(ret));
+    }
     av_freep(&vstats_filename);
 
     av_freep(&input_streams);
@@ -4200,7 +4204,10 @@ static int transcode(void)
             ost = output_streams[i];
             if (ost) {
                 if (ost->logfile) {
-                    fclose(ost->logfile);
+                    if ((ret = fclose(ost->logfile)) < 0)
+                        av_log(NULL, AV_LOG_ERROR,
+                               "Error closing logfile, loss of information possible: %s\n",
+                               av_err2str(ret));
                     ost->logfile = NULL;
                 }
                 av_freep(&ost->forced_kf_pts);
-- 
2.6.4



More information about the ffmpeg-devel mailing list