]> Git Repo - VerusCoin.git/commitdiff
Net: Fix resource leak in ReadBinaryFile(...)
authorpracticalswift <[email protected]>
Wed, 14 Jun 2017 15:32:45 +0000 (17:32 +0200)
committerJack Grigg <[email protected]>
Fri, 23 Jun 2017 06:49:43 +0000 (18:49 +1200)
Introduced in 3290567bbd54e01cb6fe6b1d04c659abca983af2 via PR #2177.

src/torcontrol.cpp

index a5cd1b7c690a664c16d373449353ed4738f64875..ffa1f75f804ed8fe2aceb72d958dc16a02eb53a0 100644 (file)
@@ -376,8 +376,10 @@ static std::pair<bool,std::string> ReadBinaryFile(const std::string &filename, s
     while ((n=fread(buffer, 1, sizeof(buffer), f)) > 0) {
         // Check for reading errors so we don't return any data if we couldn't
         // read the entire file (or up to maxsize)
-        if (ferror(f))
+        if (ferror(f)) {
+            fclose(f);
             return std::make_pair(false,"");
+        }
         retval.append(buffer, buffer+n);
         if (retval.size() > maxsize)
             break;
This page took 0.0263 seconds and 4 git commands to generate.