1
0
mirror of https://github.com/golang/go synced 2024-11-08 15:16:25 -07:00
go/src/bytes
Michael Munday 11cdbab9d4 bytes, internal/bytealg: fix incorrect IndexString usage
The IndexString implementation in the bytealg package requires that
the string passed into it be in the range '2 <= len(s) <= MaxLen'
where MaxLen may be any value (including 0).

CL 156998 added calls to bytealg.IndexString where MaxLen was not
first checked. This led to an illegal instruction on s390x with
the vector facility disabled.

This CL guards the calls to bytealg.IndexString with a MaxLen check.
If the check fails then the code now falls back to the pre CL 156998
implementation (a loop over the runes in the string).

Since the MaxLen check is now in place the generic implementation is
no longer called so I have returned it to its original unimplemented
state.

In future we may want to drop MaxLen to prevent this kind of
confusion.

Fixes #41552.

Change-Id: Ibeb3f08720444a05c08d719ed97f6cef2423bbe9
Reviewed-on: https://go-review.googlesource.com/c/go/+/256717
Run-TryBot: Michael Munday <mike.munday@ibm.com>
TryBot-Result: Go Bot <gobot@golang.org>
Trust: Michael Munday <mike.munday@ibm.com>
Reviewed-by: Keith Randall <khr@golang.org>
2020-09-23 19:55:33 +00:00
..
boundary_test.go
buffer_test.go
buffer.go
bytes_test.go strings, bytes: improve IndexAny and LastIndexAny performance 2020-03-11 05:13:13 +00:00
bytes.go bytes, internal/bytealg: fix incorrect IndexString usage 2020-09-23 19:55:33 +00:00
compare_test.go
example_test.go
export_test.go
reader_test.go
reader.go