Skip to content
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

Fix ArraIndexOutOfBoundsException #373

Merged
merged 1 commit into from
Feb 24, 2021

Conversation

Gamebuster19901
Copy link
Contributor

@Gamebuster19901 Gamebuster19901 commented Feb 24, 2021

From the discord:

https://discord.com/channels/326074836508213258/517120478557634580/814282223641296936

These return statements erroneously subtract 1 when they shouldn't which can cause the index to underflow.

Ex: If the name is 4 characters long then:

return name.substring(0, name.length() - state.spriteString().length() - 1);

is actually

return name.substring(0, 4 - 4 - 1)

4 - 4 - 1 = -1 which is less than 0, and therefor invalid.

Test before merging.

From the discord:

These return statements erroneously subtract 1 when they shouldn't which can cause the index to underflow.

Ex: If the name is 4 characters long then:
```java
return name.substring(0, name.length() - state.spriteString().length() - 1);
```
is actually 

```java
return name.substring(0, 4 - 4 - 1)
```

`4 - 4 - 1 = -1`  which is less than 0, and therefor invalid.
Copy link
Member

@nightm4re94 nightm4re94 left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thank you for addressing this so quickly!

@nightm4re94 nightm4re94 merged commit b7d469a into gurkenlabs:master Feb 24, 2021
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants