[FFmpeg-devel] [PATCH 09/13] ffserver: check fclose return value

Ganesh Ajjanagadde gajjanagadde at gmail.com
Tue Jan 12 05:25:11 CET 2016


Maybe theoretical; since all files here are opened in read only mode.
Nevertheless, it is a good idea to check the return value.

Signed-off-by: Ganesh Ajjanagadde <gajjanagadde at gmail.com>
---
 ffserver.c | 16 ++++++++++++----
 1 file changed, 12 insertions(+), 4 deletions(-)

diff --git a/ffserver.c b/ffserver.c
index bc7dbee..720d164 100644
--- a/ffserver.c
+++ b/ffserver.c
@@ -1310,7 +1310,10 @@ static FFServerIPAddressACL* parse_dynamic_acl(FFServerStream *stream,
 
     acl = av_mallocz(sizeof(FFServerIPAddressACL));
     if (!acl) {
-        fclose(f);
+        if (fclose(f))
+            av_log(NULL, AV_LOG_WARNING,
+                   "Unable to close acl file '%s': %s\n",
+                   stream->dynamic_acl, av_err2str(AVERROR(errno)));
         return NULL;
     }
 
@@ -1328,7 +1331,10 @@ static FFServerIPAddressACL* parse_dynamic_acl(FFServerStream *stream,
             ffserver_parse_acl_row(NULL, NULL, acl, p, stream->dynamic_acl,
                                    line_num);
     }
-    fclose(f);
+    if (fclose(f))
+            av_log(NULL, AV_LOG_WARNING,
+                   "Unable to close acl file '%s': %s\n",
+                   stream->dynamic_acl, av_err2str(AVERROR(errno)));
     return acl;
 }
 
@@ -2076,8 +2082,10 @@ static void compute_status(HTTPContext *c)
                                          "Total time used %s.\n",
                                      cpuperc, cpuused);
                      }
-                     fclose(pid_stat);
-                 }
+                     if (fclose(pid_stat))
+                        av_log(NULL, AV_LOG_WARNING,
+                               "Unable to close pid stat '%s': %s\n",
+                               ps_cmd, av_err2str(AVERROR(errno)));
             }
 #endif
 
-- 
2.7.0



More information about the ffmpeg-devel mailing list