fix(stringx): reject start > stop in Substr to prevent slice panic (#5616)

Signed-off-by: Sai Asish Y <say.apm35@gmail.com>
This commit is contained in:
Sai Asish Y
2026-06-20 21:13:44 -07:00
committed by GitHub
parent 1aecffc306
commit d4882c1da0
2 changed files with 8 additions and 1 deletions

View File

@@ -132,7 +132,7 @@ func Substr(str string, start, stop int) (string, error) {
return "", ErrInvalidStartPosition
}
if stop < 0 || stop > length {
if stop < 0 || stop > length || start > stop {
return "", ErrInvalidStopPosition
}