[USER32]: Use RtlInitEmptyUnicodeString where needed. Fix CID 1401230 and CID 701428...
authorHermès Bélusca-Maïto <hermes.belusca-maito@reactos.org>
Sun, 5 Mar 2017 01:20:40 +0000 (01:20 +0000)
committerHermès Bélusca-Maïto <hermes.belusca-maito@reactos.org>
Sun, 5 Mar 2017 01:20:40 +0000 (01:20 +0000)
svn path=/trunk/; revision=74071

reactos/win32ss/user/user32/windows/class.c

index 3127f8e..25bdd43 100644 (file)
@@ -215,8 +215,7 @@ VersionRegisterClass(
             {
                 if (IS_ATOM(pszClass))
                 {
-                    ClassName.Buffer = ClassNameBuf;
-                    ClassName.MaximumLength = sizeof(ClassNameBuf);
+                    RtlInitEmptyUnicodeString(&ClassName, ClassNameBuf, sizeof(ClassNameBuf));
                     if (!NtUserGetAtomName(LOWORD((DWORD_PTR)pszClass), &ClassName))
                     {
                         ERR("Error while verifying ATOM\n");
@@ -1027,8 +1026,9 @@ GetClassNameW(
     UNICODE_STRING ClassName;
     int Result;
 
-    ClassName.MaximumLength = nMaxCount * sizeof(WCHAR);
-    ClassName.Buffer = lpClassName;
+    RtlInitEmptyUnicodeString(&ClassName,
+                              lpClassName,
+                              nMaxCount * sizeof(WCHAR));
 
     Result = NtUserGetClassName(hWnd,
                                 FALSE,
@@ -1214,8 +1214,10 @@ RealGetWindowClassW(
   UINT  cchType)
 {
     UNICODE_STRING ClassName;
-    ClassName.MaximumLength = cchType * sizeof(WCHAR);
-    ClassName.Buffer = (PWSTR)pszType;
+
+    RtlInitEmptyUnicodeString(&ClassName,
+                              pszType,
+                              cchType * sizeof(WCHAR));
 
     return NtUserGetClassName(hwnd,TRUE,&ClassName);
 }