浏览代码

Merge pull request #1923 from bryongloden/patch-1

close opened file descriptors properly
Feng Xiao 9 年之前
父节点
当前提交
1102a8a767
共有 1 个文件被更改,包括 1 次插入0 次删除
  1. 1 0
      src/google/protobuf/testing/file.cc

+ 1 - 0
src/google/protobuf/testing/file.cc

@@ -91,6 +91,7 @@ bool File::WriteStringToFile(const string& contents, const string& name) {
 
   if (fwrite(contents.data(), 1, contents.size(), file) != contents.size()) {
     GOOGLE_LOG(ERROR) << "fwrite(" << name << "): " << strerror(errno);
+    fclose(file);
     return false;
   }