https://git.reactos.org/?p=reactos.git;a=commitdiff;h=127fa1afc6c7fa6a264ce0eb442e8a7523a8327f

commit 127fa1afc6c7fa6a264ce0eb442e8a7523a8327f
Author:     Hermès Bélusca-Maïto <[email protected]>
AuthorDate: Thu Jan 2 21:10:42 2020 +0100
Commit:     Hermès Bélusca-Maïto <[email protected]>
CommitDate: Thu Jan 2 21:11:28 2020 +0100

    [RTL] Fix RtlValidateUnicodeString() regarding the tests and add some SAL 
annotations.
---
 sdk/lib/rtl/unicode.c | 32 +++++++++++++++++---------------
 1 file changed, 17 insertions(+), 15 deletions(-)

diff --git a/sdk/lib/rtl/unicode.c b/sdk/lib/rtl/unicode.c
index 7d2470a9591..7f045401326 100644
--- a/sdk/lib/rtl/unicode.c
+++ b/sdk/lib/rtl/unicode.c
@@ -2541,22 +2541,24 @@ RtlDuplicateUnicodeString(
  */
 NTSTATUS
 NTAPI
-RtlValidateUnicodeString(IN ULONG Flags,
-                         IN PCUNICODE_STRING UnicodeString)
+RtlValidateUnicodeString(
+    _In_ ULONG Flags,
+    _In_ PCUNICODE_STRING String)
 {
-    /* currently no flags are supported! */
-    ASSERT(Flags == 0);
-
-    if ((Flags == 0) &&
-        ((UnicodeString == NULL) ||
-         ((UnicodeString->Length != 0) &&
-          (UnicodeString->Buffer != NULL) &&
-          ((UnicodeString->Length % sizeof(WCHAR)) == 0) &&
-          ((UnicodeString->MaximumLength % sizeof(WCHAR)) == 0) &&
-          (UnicodeString->MaximumLength >= UnicodeString->Length))))
-    {
-        /* a NULL pointer as a unicode string is considered to be a valid 
unicode
-           string! */
+    /* In Windows <= 2003 no flags are supported yet! */
+    if (Flags != 0)
+        return STATUS_INVALID_PARAMETER;
+
+    /* NOTE: a NULL Unicode string pointer is considered to be a valid one! */
+    if (String == NULL)
+    {
+        return STATUS_SUCCESS;
+    }
+    else if (!((String->Buffer == NULL) && (String->Length != 0 || 
String->MaximumLength != 0)) &&
+              (String->Length % sizeof(WCHAR) == 0) &&
+              (String->MaximumLength % sizeof(WCHAR) == 0) &&
+              (String->Length <= String->MaximumLength))
+    {
         return STATUS_SUCCESS;
     }
     else

Reply via email to