$include_dir="/home/hyper-archives/boost-commit/include"; include("$include_dir/msg-header.inc") ?>
Subject: [Boost-commit] svn:boost r83967 - trunk/libs/regex/src
From: john_at_[hidden]
Date: 2013-04-19 13:45:24
Author: johnmaddock
Date: 2013-04-19 13:45:22 EDT (Fri, 19 Apr 2013)
New Revision: 83967
URL: http://svn.boost.org/trac/boost/changeset/83967
Log:
Fix buffer size determination.
Fixes #8082.
Text files modified: 
   trunk/libs/regex/src/w32_regex_traits.cpp |    12 +++++++-----                            
   1 files changed, 7 insertions(+), 5 deletions(-)
Modified: trunk/libs/regex/src/w32_regex_traits.cpp
==============================================================================
--- trunk/libs/regex/src/w32_regex_traits.cpp	(original)
+++ trunk/libs/regex/src/w32_regex_traits.cpp	2013-04-19 13:45:22 EDT (Fri, 19 Apr 2013)
@@ -283,9 +283,11 @@
    if (r == 0)
       return def;
 
-   LPSTR buf = (LPSTR)_alloca( (r + 1) * 2 );
-   if (::WideCharToMultiByte(CP_ACP, 0,  wbuf, r,  buf, (r + 1) * 2,  NULL, NULL) == 0)
-      return def;
+
+   int buf_size = 1 + ::WideCharToMultiByte(CP_ACP, 0,  wbuf, r,  NULL, 0,  NULL, NULL);
+   LPSTR buf = (LPSTR)_alloca(buf_size);
+   if (::WideCharToMultiByte(CP_ACP, 0,  wbuf, r,  buf, buf_size,  NULL, NULL) == 0)
+      return def; // failed conversion.
 #endif
    return std::string(buf);
 }
@@ -485,7 +487,7 @@
       return c;
 
    if (::WideCharToMultiByte(code_page, 0,  &wide_result, 1,  result, 2,  NULL, NULL) == 0)
-       return c;
+       return c;  // No single byte lower case equivalent available
 #endif
    return result[0];
 }
@@ -556,7 +558,7 @@
       return c;
 
    if (::WideCharToMultiByte(code_page, 0,  &wide_result, 1,  result, 2,  NULL, NULL) == 0)
-       return c;
+       return c;  // No single byte upper case equivalent available.
 #endif
    return result[0];
 }