Skip to content

bug: len(byteArray) can be minus without panic #732

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Closed
hajimehoshi opened this issue Dec 25, 2017 · 0 comments
Closed

bug: len(byteArray) can be minus without panic #732

hajimehoshi opened this issue Dec 25, 2017 · 0 comments
Assignees

Comments

@hajimehoshi
Copy link
Member

package main

import (
	"fmt"
)

func main() {
	a := make([]byte, 4096)
	b := a[8192:]
	fmt.Println(len(b))
}

https://gopherjs.github.io/playground/#/Sxg5Yfe4Y0

Actual result:
-4096

Expected result:
panic: runtime error: slice bounds out of range

@hajimehoshi hajimehoshi self-assigned this Mar 13, 2018
hajimehoshi added a commit to hajimehoshi/gopherjs that referenced this issue Mar 13, 2018
hajimehoshi added a commit that referenced this issue Mar 15, 2018
In $subslice function in prelude, it was checked whether the arguments high/max were in the given slice's range. This was done even when high/max were not given, and the range check didn't work in this case. This commit fixes this issue by ensuring high/max values to use the slice's length and capacity values as default values.

Fixes #732.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

2 participants