stdcxx-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From se...@apache.org
Subject svn commit: r692472 - /stdcxx/branches/4.2.x/src/collate.cpp
Date Fri, 05 Sep 2008 16:00:23 GMT
Author: sebor
Date: Fri Sep  5 09:00:22 2008
New Revision: 692472

URL: http://svn.apache.org/viewvc?rev=692472&view=rev
Log:
2008-09-05  Martin Sebor  <sebor@roguewave.com>

	STDCXX-1010
	* src/collate.cpp [_RWSTD_OS_SUNOS] (__rw_strnxfrm): Passed
	NULL to strxfrm() on Solaris to avoid memory corruption due
	to a bug in some releases of the OS.
	[_RWSTD_OS_SUNOS] (__rw_wcsnxfrm): Same but for wcsxfrm().

Modified:
    stdcxx/branches/4.2.x/src/collate.cpp

Modified: stdcxx/branches/4.2.x/src/collate.cpp
URL: http://svn.apache.org/viewvc/stdcxx/branches/4.2.x/src/collate.cpp?rev=692472&r1=692471&r2=692472&view=diff
==============================================================================
--- stdcxx/branches/4.2.x/src/collate.cpp (original)
+++ stdcxx/branches/4.2.x/src/collate.cpp Fri Sep  5 09:00:22 2008
@@ -522,10 +522,17 @@
             src    += (last - src) + 1;
         }
 
+#ifdef _RWSTD_OS_SUNOS
+        // Solaris 10u5 on AMD64 overwrites memory past the end of
+        // just_in_case_buf[8], to avoid this, pass a null pointer
+        char* const just_in_case_buf = 0;
+#else
         // provide a destination buffer to strxfrm() in case
         // it's buggy (such as MSVC's) and tries to write to
         // the buffer even if it's 0
         char just_in_case_buf [8];
+#endif
+
         const _RWSTD_SIZE_T dst_size = strxfrm (just_in_case_buf, psrc, 0);
 
         // check for strxfrm() errors
@@ -724,10 +731,16 @@
             src    += (last - src) + 1;
         }
 
+#ifdef _RWSTD_OS_SUNOS
+        // just in case Solaris wcsxfrm() has the same bug
+        // as its strxfrm() (see above)
+        wchar_t* const just_in_case_buf = 0;
+#else
         // provide a destination buffer to strxfrm() in case
         // it's buggy (such as MSVC's) and tries to write to
         // the buffer even if it's 0
         wchar_t just_in_case_buf [8];
+#endif
 
         const _RWSTD_SIZE_T dst_size =
             _RWSTD_WCSXFRM (just_in_case_buf, psrc, 0);



Mime
View raw message