Fix resources leaks
authorPierre Schweitzer <pierre@reactos.org>
Tue, 13 Mar 2012 10:25:42 +0000 (11:25 +0100)
committerPierre Schweitzer <pierre@reactos.org>
Tue, 13 Mar 2012 10:25:42 +0000 (11:25 +0100)
src/build_log.cc
src/disk_interface.cc

index 4b93931ba2504a927a555ca3f9875b2e9bec09ad..fd93ea8edc9d299d2ddfefbf217e6b23739827c2 100644 (file)
@@ -221,6 +221,7 @@ bool BuildLog::Recompact(const string& path, string* err) {
 
   if (fprintf(f, kFileSignature, kCurrentVersion) < 0) {
     *err = strerror(errno);
+    fclose(f);
     return false;
   }
 
index b1a174602568a89b16b426466e4308f22ad48164..5a36685965d14bf6f02030bd74ab26ab6292c33f 100644 (file)
@@ -109,9 +109,10 @@ bool RealDiskInterface::WriteFile(const string & path, const string & contents)
     Error("WriteFile(%s): Unable to create file. %s", path.c_str(), strerror(errno));
     return false;
   }
+
   if (fwrite(contents.data(), 1, contents.length(), fp) < contents.length())  {
     Error("WriteFile(%s): Unable to write to the file. %s", path.c_str(), strerror(errno));
+    fclose(fp);
     return false;
   }