8180945: vmError.cpp : adjust dup and fclose
authormbaesken
Thu, 25 May 2017 20:55:20 -0400
changeset 46501 6b4919b83092
parent 46500 182d2a50464a
child 46502 116a09d8f142
8180945: vmError.cpp : adjust dup and fclose Reviewed-by: dholmes
hotspot/src/share/vm/utilities/vmError.cpp
--- a/hotspot/src/share/vm/utilities/vmError.cpp	Thu May 25 23:20:29 2017 +0000
+++ b/hotspot/src/share/vm/utilities/vmError.cpp	Thu May 25 20:55:20 2017 -0400
@@ -1331,12 +1331,14 @@
     if (!transmit_report_done && should_report_bug(_id)) {
       transmit_report_done = true;
       const int fd2 = ::dup(log.fd());
-      FILE* const hs_err = ::fdopen(fd2, "r");
-      if (NULL != hs_err) {
-        ErrorReporter er;
-        er.call(hs_err, buffer, O_BUFLEN);
+      if (fd2 != -1) {
+        FILE* const hs_err = ::fdopen(fd2, "r");
+        if (NULL != hs_err) {
+          ErrorReporter er;
+          er.call(hs_err, buffer, O_BUFLEN);
+          ::fclose(hs_err);
+        }
       }
-      ::fclose(hs_err);
     }
 
     if (log.fd() != defaultStream::output_fd()) {