From dfd5ee6b5dd243a765fb84c37ece39aa5a480775 Mon Sep 17 00:00:00 2001 From: Andreas Hausladen Date: Tue, 2 Oct 2018 09:21:28 +0200 Subject: [PATCH] Fixed Mantis #6634: Access violation in JvJCLUtils: GetWordOnPos2 --- jvcl/run/JvJCLUtils.pas | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/jvcl/run/JvJCLUtils.pas b/jvcl/run/JvJCLUtils.pas index 19f70da226..732bed6e07 100644 --- a/jvcl/run/JvJCLUtils.pas +++ b/jvcl/run/JvJCLUtils.pas @@ -1465,7 +1465,7 @@ function GetWordOnPosW(const S: WideString; const P: Integer): WideString; function GetWordOnPos2(const S: string; P: Integer; var iBeg, iEnd: Integer): string; begin Result := ''; - if P < 1 then + if (P > Length(S)) or (P < 1) then Exit; if CharInSet(S[P], Separators) and ((P < 1) or CharInSet(S[P - 1], Separators)) then Inc(P); @@ -1491,7 +1491,7 @@ function GetWordOnPos2(const S: string; P: Integer; var iBeg, iEnd: Integer): st function GetWordOnPos2W(const S: WideString; P: Integer; var iBeg, iEnd: Integer): WideString; begin Result := ''; - if P < 1 then + if (P > Length(S)) or (P < 1) then Exit; if CharInSetW(S[P], Separators) and ((P < 1) or (CharInSetW(S[P - 1], Separators))) then