浏览代码

HPCC-10552 Fix regression calling close(-1) (caught in windows debug)

Signed-off-by: Gavin Halliday <gavin.halliday@lexisnexis.com>
Gavin Halliday 11 年之前
父节点
当前提交
00e087191d
共有 1 个文件被更改,包括 11 次插入5 次删除
  1. 11 5
      tools/hidl/hidlcomp.cpp

+ 11 - 5
tools/hidl/hidlcomp.cpp

@@ -6640,6 +6640,12 @@ char* getTargetBase(const char* outDir, const char* src)
         return strdup(src);
 }
 
+static void safeclose(int fh)
+{
+    if (fh >= 0)
+        close(fh);
+}
+
 HIDLcompiler::HIDLcompiler(const char * sourceFile,const char *outDir)
 {
     modules = NULL;
@@ -6683,11 +6689,11 @@ HIDLcompiler::~HIDLcompiler()
     close(cppo);
     //close(xsvo);
     close(clwo);
-    close(espx);
-    close(espng);
-    close(espngc);
-    close(espi);
-    close(espc);
+    safeclose(espx);
+    safeclose(espng);
+    safeclose(espngc);
+    safeclose(espi);
+    safeclose(espc);
     free(packagename);
     free(filename);