delphidabbler / codesnip

A code bank designed with Pascal in mind
https://delphidabbler.com/software/codesnip
Other
110 stars 33 forks source link

Bug in `StrCompressWhiteSpace` function of `UStrUtils` unit #95

Closed delphidabbler closed 1 year ago

delphidabbler commented 1 year ago

This unit can generated an out of bounds error when following white space is at the end of a string. The Idx index can go beyond the end of the string.

The bug is in the line:

https://github.com/delphidabbler/codesnip/blob/02656b8417c2863a89cf2bf45e3be275ca9f94a9/Src/UStrUtils.pas#L407

A fix is to change the above line to:

while (Idx <= Length(Str)) and TCharacter.IsWhiteSpace(Str[Idx]) do
delphidabbler commented 1 year ago

Fixed at merge commit 60f68dc8f0ac5f18791d52bd09c221b134463b9d