Browse Source

Don't trigger range check error in PathLastChar.

There was no actual out-of-range access and this didn't affect established projects at all (where range checking is never enabled), but it could be seen in new projects.

The PathStrPrevChar call was only relevant to DBCS in non-Unicode builds.
Jordan Russell 5 months ago
parent
commit
147a5aaadc
1 changed files with 4 additions and 2 deletions
  1. 4 2
      Components/PathFunc.pas

+ 4 - 2
Components/PathFunc.pas

@@ -2,7 +2,7 @@ unit PathFunc;
 
 {
   Inno Setup
-  Copyright (C) 1997-2024 Jordan Russell
+  Copyright (C) 1997-2025 Jordan Russell
   Portions by Martijn Laan
   For conditions of distribution and use, see LICENSE.TXT.
 
@@ -47,6 +47,8 @@ function RemoveBackslashUnlessRoot(const S: String): String;
 
 implementation
 
+{$ZEROBASEDSTRINGS OFF}
+
 uses
   Windows, SysUtils;
 
@@ -386,7 +388,7 @@ begin
   if S = '' then
     Result := nil
   else
-    Result := PathStrPrevChar(Pointer(S), @S[Length(S)+1]);
+    Result := @S[High(S)];
 end;
 
 function PathLastDelimiter(const Delimiters, S: string): Integer;