Author: gschneider
Date: Sun Apr 12 01:24:25 2009
New Revision: 40469

URL: http://svn.reactos.org/svn/reactos?rev=40469&view=rev
Log:
- Don't copy data to null buffer, just return the string length in this case
- Fix some buffer calculation problems, handle buffer termination if it's 
shorter than the font string
- Fixes >= 10 gdi32 font winetests (NtGdiGetTextFaceW/NtGdiGetTextFaceA related)

Modified:
    trunk/reactos/subsystems/win32/win32k/objects/text.c

Modified: trunk/reactos/subsystems/win32/win32k/objects/text.c
URL: 
http://svn.reactos.org/svn/reactos/trunk/reactos/subsystems/win32/win32k/objects/text.c?rev=40469&r1=40468&r2=40469&view=diff
==============================================================================
--- trunk/reactos/subsystems/win32/win32k/objects/text.c [iso-8859-1] (original)
+++ trunk/reactos/subsystems/win32/win32k/objects/text.c [iso-8859-1] Sun Apr 
12 01:24:25 2009
@@ -326,6 +326,7 @@
    HFONT hFont;
    PTEXTOBJ TextObj;
    NTSTATUS Status;
+   INT fLen, ret;
 
    /* FIXME: Handle bAliasName */
 
@@ -341,16 +342,32 @@
 
    TextObj = RealizeFontInit(hFont);
    ASSERT(TextObj != NULL);
-   Count = min(Count, 
wcslen(TextObj->logfont.elfEnumLogfontEx.elfLogFont.lfFaceName));
-   Status = MmCopyToCaller(FaceName, 
TextObj->logfont.elfEnumLogfontEx.elfLogFont.lfFaceName, Count * sizeof(WCHAR));
+   fLen = wcslen(TextObj->logfont.elfEnumLogfontEx.elfLogFont.lfFaceName) + 1;
+
+   if (FaceName != NULL)
+   {
+      Count = min(Count, fLen);
+      Status = MmCopyToCaller(FaceName, 
TextObj->logfont.elfEnumLogfontEx.elfLogFont.lfFaceName, Count * sizeof(WCHAR));
+      if (!NT_SUCCESS(Status))
+      {
+         TEXTOBJ_UnlockText(TextObj);
+         SetLastNtError(Status);
+         return 0;
+      }
+      /* Terminate if we copied only part of the font name */
+      if (Count > 0 && Count < fLen)
+      {
+         FaceName[Count - 1] = '\0';
+      }
+      ret = Count;
+   }
+   else
+   {
+      ret = fLen; 
+   }
+
    TEXTOBJ_UnlockText(TextObj);
-   if (!NT_SUCCESS(Status))
-   {
-      SetLastNtError(Status);
-      return 0;
-   }
-
-   return Count;
+   return ret;
 }
 
 W32KAPI

Reply via email to