trafficserver-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From bc...@apache.org
Subject [trafficserver] branch master updated: cppcheck: fixed leak and scoping in ts::file::copy
Date Tue, 06 Aug 2019 22:05:36 GMT
This is an automated email from the ASF dual-hosted git repository.

bcall pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/trafficserver.git


The following commit(s) were added to refs/heads/master by this push:
     new a858e49  cppcheck: fixed leak and scoping in ts::file::copy
a858e49 is described below

commit a858e492807391d487a486076c07f1e495eda7b8
Author: Bryan Call <bcall@apache.org>
AuthorDate: Thu Jul 25 11:45:08 2019 -0400

    cppcheck: fixed leak and scoping in ts::file::copy
---
 src/tscore/ts_file.cc | 6 +++---
 1 file changed, 3 insertions(+), 3 deletions(-)

diff --git a/src/tscore/ts_file.cc b/src/tscore/ts_file.cc
index d50fae3..b15386f 100644
--- a/src/tscore/ts_file.cc
+++ b/src/tscore/ts_file.cc
@@ -156,7 +156,6 @@ namespace file
   {
     static int BUF_SIZE = 65536;
     FILE *src, *dst;
-    size_t in, out;
     char buf[BUF_SIZE];
     int bufsize = BUF_SIZE;
 
@@ -184,14 +183,15 @@ namespace file
     }
     if (nullptr == (dst = fopen(final_to.c_str(), "w"))) {
       ec = std::error_code(errno, std::system_category());
+      fclose(src);
       return false;
     }
 
     while (1) {
-      in = fread(buf, 1, bufsize, src);
+      size_t in = fread(buf, 1, bufsize, src);
       if (0 == in)
         break;
-      out = fwrite(buf, 1, in, dst);
+      size_t out = fwrite(buf, 1, in, dst);
       if (0 == out)
         break;
     }


Mime
View raw message