stdcxx-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From far...@apache.org
Subject svn commit: r587117 - /incubator/stdcxx/branches/4.2.x/tests/src/printf.cpp
Date Mon, 22 Oct 2007 14:51:02 GMT
Author: faridz
Date: Mon Oct 22 07:51:01 2007
New Revision: 587117

URL: http://svn.apache.org/viewvc?rev=587117&view=rev
Log:
2007-10-22 Travis Vitek <vitek@roguewave.com>

	STDCXX-581
	* printf.cpp (_rw_fmtstr): Provide reasonable length value
	to call to __rw_memattr() to avoid touching uninitialized
	memory.
	(_rwfmtwstr): Ditto.
	(_rwfmtarray): Ditto.

Modified:
    incubator/stdcxx/branches/4.2.x/tests/src/printf.cpp

Modified: incubator/stdcxx/branches/4.2.x/tests/src/printf.cpp
URL: http://svn.apache.org/viewvc/incubator/stdcxx/branches/4.2.x/tests/src/printf.cpp?rev=587117&r1=587116&r2=587117&view=diff
==============================================================================
--- incubator/stdcxx/branches/4.2.x/tests/src/printf.cpp (original)
+++ incubator/stdcxx/branches/4.2.x/tests/src/printf.cpp Mon Oct 22 07:51:01 2007
@@ -1933,7 +1933,10 @@
 {
     RW_ASSERT (0 != buf.pbuf);
 
-    if (   0 == array || 0 > _RW::__rw_memattr (array, _RWSTD_SIZE_MAX, -1)
+    const size_t memlen =   _RWSTD_SIZE_MAX == nelems
+                          ? _RWSTD_SIZE_MAX : nelems * sizeof *array;
+    if (   0 == array
+        || 0 > _RW::__rw_memattr (array, memlen, -1)
         || ((size_t)array & (sizeof *array - 1))) {
         // qualify the name of the static function in order to
         // allow it to be found when referenced from a template
@@ -2369,7 +2372,7 @@
     if (spec.fl_pound)
         return _rw_fmtarray (spec, buf, str, len, A_CHAR | A_ESC);
 
-    if (0 == str || 0 > _RW::__rw_memattr (str, _RWSTD_SIZE_MAX, -1))
+    if (0 == str || 0 > _RW::__rw_memattr (str, len, -1))
         return _rw_fmtbadaddr (spec, buf, str);
 
     if (_RWSTD_SIZE_MAX == len)
@@ -2440,7 +2443,10 @@
         return _rw_fmtarray (spec, buf, wstr, len, flags);
     }
 
-    if (   0 == wstr || 0 > _RW::__rw_memattr (wstr, _RWSTD_SIZE_MAX, -1)
+    const size_t memlen =   _RWSTD_SIZE_MAX == len
+                          ? _RWSTD_SIZE_MAX : len * sizeof *wstr;
+    if (   0 == wstr
+        || 0 > _RW::__rw_memattr (wstr, memlen, -1)
         || ((size_t)wstr & (sizeof *wstr - 1)))
         return _rw_fmtbadaddr (spec, buf, wstr, sizeof *wstr);
 



Mime
View raw message