From b91d9c423cfeb9b90120baf856274f9c2e9a62f0 Mon Sep 17 00:00:00 2001
From: Christophe Geuzaine <cgeuzaine@ulg.ac.be>
Date: Fri, 16 Nov 2012 20:30:37 +0000
Subject: [PATCH] fix

---
 Common/OS.cpp | 9 ++++++---
 1 file changed, 6 insertions(+), 3 deletions(-)

diff --git a/Common/OS.cpp b/Common/OS.cpp
index dd8bfdd1f4..e04130fa3f 100644
--- a/Common/OS.cpp
+++ b/Common/OS.cpp
@@ -263,15 +263,18 @@ void RedirectIOToConsole()
   // redirect unbuffered stdout, stdin and stderr to the console
   intptr_t lStdHandle = (intptr_t)GetStdHandle(STD_OUTPUT_HANDLE);
   int hConHandle = _open_osfhandle(lStdHandle, _O_TEXT);
-  *stdout = _fdopen(hConHandle, "w");
+  FILE *fp = _fdopen(hConHandle, "w");
+  *stdout = *fp;
   setvbuf(stdout, NULL, _IONBF, 0);
   lStdHandle = (intptr_t)GetStdHandle(STD_INPUT_HANDLE);
   hConHandle = _open_osfhandle(lStdHandle, _O_TEXT);
-  *stdin = _fdopen(hConHandle, "r");
+  fp = _fdopen(hConHandle, "r");
+  *stdin = *fp;
   setvbuf(stdin, NULL, _IONBF, 0);
   lStdHandle = (intptr_t)GetStdHandle(STD_ERROR_HANDLE);
   hConHandle = _open_osfhandle(lStdHandle, _O_TEXT);
-  *stderr = _fdopen(hConHandle, "w");
+  fp = _fdopen(hConHandle, "w");
+  *stderr = *fp;
   setvbuf(stderr, NULL, _IONBF, 0);
   // make cout, wcout, cin, wcin, wcerr, cerr, wclog and clog point to 
   // console as well
-- 
GitLab