From f2cda7a4a8ba1f5e5db1ddbd43e57606a4b36f72 Mon Sep 17 00:00:00 2001 From: Michael Smith Date: Mon, 7 Dec 2015 10:39:52 -0800 Subject: [PATCH] Fix iostream output on older Windows WriteConsoleW originally required the lpNumberOfCharsWritten argument. That seems to have changed in later releases, but is required for Windows Server 2003 and 2008. Fix a seg fault by passing the required argument. --- src/iostream.cpp | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/iostream.cpp b/src/iostream.cpp index b68945a..6b90991 100644 --- a/src/iostream.cpp +++ b/src/iostream.cpp @@ -64,8 +64,8 @@ namespace details { namespace uf = boost::locale::utf; char const *b = p; char const *e = p+n; + DWORD size=0; if(!isatty_) { - DWORD size=0; if(!WriteFile(handle_,p,n,&size,0) || static_cast(size) != n) return -1; return n; @@ -81,7 +81,7 @@ namespace details { } if(c==uf::illegal) return -1; - if(!WriteConsoleW(handle_,wbuffer_,out - wbuffer_,0,0)) + if(!WriteConsoleW(handle_,wbuffer_,out - wbuffer_,&size,0)) return -1; return decoded; }