[ros-diffs] [sgasiorek] 19845: fix for LoadStringA - return part of string if buffer is to small

sgasiorek at svn.reactos.com sgasiorek at svn.reactos.com
Sat Dec 3 22:01:00 CET 2005


fix for LoadStringA - return part of string if buffer is to small
Modified: trunk/reactos/lib/user32/misc/resources.c
  _____  

Modified: trunk/reactos/lib/user32/misc/resources.c
--- trunk/reactos/lib/user32/misc/resources.c	2005-12-03 20:53:23 UTC
(rev 19844)
+++ trunk/reactos/lib/user32/misc/resources.c	2005-12-03 21:00:55 UTC
(rev 19845)
@@ -98,7 +98,7 @@

 {
  UNICODE_STRING wstrResStr;
  ANSI_STRING strBuf;
- NTSTATUS nErrCode;
+ INT retSize;
 
  /* parameter validation */
  if
@@ -125,14 +125,13 @@
  strBuf.MaximumLength = nBufferMax * sizeof(CHAR);
  strBuf.Buffer = lpBuffer;
 
- nErrCode = RtlUnicodeStringToAnsiString(&strBuf, &wstrResStr, FALSE);
+ retSize = WideCharToMultiByte(CP_ACP, 0, wstrResStr.Buffer,
wstrResStr.Length / sizeof(WCHAR), strBuf.Buffer, strBuf.MaximumLength,
NULL, NULL);
 
- if(!NT_SUCCESS(nErrCode))
- {
+ if(!retSize)
   /* failure */
-  RtlNtStatusToDosError(nErrCode);
   return 0;
- }
+ else 
+  strBuf.Length = retSize;
 
  /* the ANSI string may not be null-terminated */
  if(strBuf.Length >= strBuf.MaximumLength)
-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://www.reactos.org/pipermail/ros-diffs/attachments/20051203/72d2ffee/attachment.html


More information about the Ros-diffs mailing list