浏览代码

cmake: Fix resource leak reported by cppcheck

Return early in cmake::ReportUndefinedPropertyAccesses if there is no
global generator instead of opening a file and leaking the descriptor.

Reported-by: Ömer Fadıl USTA <[email protected]>
Brad King 12 年之前
父节点
当前提交
a20c819f63
共有 1 个文件被更改,包括 4 次插入4 次删除
  1. 4 4
      Source/cmake.cxx

+ 4 - 4
Source/cmake.cxx

@@ -3667,11 +3667,11 @@ void cmake::RecordPropertyAccess(const char *name,
 
 void cmake::ReportUndefinedPropertyAccesses(const char *filename)
 {
+  if(!this->GlobalGenerator)
+    { return; }
   FILE *progFile = fopen(filename,"w");
-  if (!progFile || !this->GlobalGenerator)
-    {
-    return;
-    }
+  if(!progFile)
+    { return; }
 
   // what are the enabled languages?
   std::vector<std::string> enLangs;