Piotr Caban : msvcrt: Add parameters to mimic *_s function behaviour in pf_vsnprintf.

Alexandre Julliard julliard at winehq.org
Mon Apr 19 11:51:16 CDT 2010


Module: wine
Branch: master
Commit: 09a32152d557ed17797fe174a64aed8a1fb8b5dd
URL:    http://source.winehq.org/git/wine.git/?a=commit;h=09a32152d557ed17797fe174a64aed8a1fb8b5dd

Author: Piotr Caban <piotr at codeweavers.com>
Date:   Mon Apr 19 10:57:31 2010 +0200

msvcrt: Add parameters to mimic *_s function behaviour in pf_vsnprintf.

---

 dlls/msvcrt/wcs.c |   18 +++++++++++++++---
 1 files changed, 15 insertions(+), 3 deletions(-)

diff --git a/dlls/msvcrt/wcs.c b/dlls/msvcrt/wcs.c
index 182af01..7c5a19f 100644
--- a/dlls/msvcrt/wcs.c
+++ b/dlls/msvcrt/wcs.c
@@ -554,7 +554,8 @@ static void pf_fixup_exponent( char *buf )
  *
  *  implements both A and W vsnprintf functions
  */
-static int pf_vsnprintf( pf_output *out, const WCHAR *format, MSVCRT__locale_t locale, __ms_va_list valist )
+static int pf_vsnprintf( pf_output *out, const WCHAR *format,
+        MSVCRT__locale_t locale, BOOL valid, __ms_va_list valist )
 {
     int r;
     LPCWSTR q, p = format;
@@ -785,9 +786,20 @@ static int pf_vsnprintf( pf_output *out, const WCHAR *format, MSVCRT__locale_t l
             r = pf_output_stringA( out, x, -1 );
             if( x != number )
                 HeapFree( GetProcessHeap(), 0, x );
+            if(r < 0)
+                return r;
         }
         else
+        {
+            if( valid )
+            {
+                MSVCRT__invalid_parameter( NULL, NULL, NULL, 0, 0 );
+                *MSVCRT__errno() = MSVCRT_EINVAL;
+                return -1;
+            }
+
             continue;
+        }
 
         if( r<0 )
             return r;
@@ -821,7 +833,7 @@ int CDECL MSVCRT_vsnprintf( char *str, unsigned int len,
     formatW = HeapAlloc( GetProcessHeap(), 0, sz*sizeof(WCHAR) );
     MultiByteToWideChar( CP_ACP, 0, format, -1, formatW, sz );
 
-    r = pf_vsnprintf( &out, formatW, NULL, valist );
+    r = pf_vsnprintf( &out, formatW, NULL, FALSE, valist );
 
     HeapFree( GetProcessHeap(), 0, formatW );
 
@@ -878,7 +890,7 @@ int CDECL MSVCRT_vsnwprintf( MSVCRT_wchar_t *str, unsigned int len,
     out.used = 0;
     out.len = len;
 
-    return pf_vsnprintf( &out, format, NULL, valist );
+    return pf_vsnprintf( &out, format, NULL, FALSE, valist );
 }
 
 /*********************************************************************




More information about the wine-cvs mailing list