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 <[EMAIL PROTECTED]>

        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);
 


Reply via email to