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

@@ -356,6 +356,13 @@ func TestSubstr(t *testing.T) {
err: ErrInvalidStopPosition,
expect: "",
},
{
input: "hello",
start: 3,
stop: 2,
err: ErrInvalidStopPosition,
expect: "",
},
}
for _, each := range cases {