[NTOSKRNL] Do not try to access OldBackTracking[-1]
authorBartosz Brachaczek <b.brachaczek@gmail.com>
Mon, 1 Apr 2019 00:09:23 +0000 (02:09 +0200)
committerPierre Schweitzer <pierre@reactos.org>
Mon, 1 Apr 2019 06:28:00 +0000 (08:28 +0200)
It can be triggered by the existing "F<", "FILE.TXT" case in the tests.

CORE-15902

ntoskrnl/fsrtl/dbcsname.c

index 3b1afd8..362549e 100644 (file)
@@ -248,7 +248,7 @@ FsRtlIsDbcsInExpression(IN PANSI_STRING Expression,
         if (NamePosition >= Name->Length)
         {
             EndOfName = TRUE;
-            if (OldBackTracking[MatchingChars - 1] == Expression->Length * 2)
+            if (MatchingChars && OldBackTracking[MatchingChars - 1] == Expression->Length * 2)
                 break;
         }
         else
@@ -422,7 +422,7 @@ FsRtlIsDbcsInExpression(IN PANSI_STRING Expression,
     }
 
     /* Store result value */
-    Result = (OldBackTracking[MatchingChars - 1] == Expression->Length * 2);
+    Result = MatchingChars && (OldBackTracking[MatchingChars - 1] == Expression->Length * 2);
 
 Exit: