The Wayback Machine - https://web.archive.org/web/20210111193429/https://github.com/PhilJay/MPAndroidChart/pull/5055
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

Test for null in entry.getRanges() #5055

Open
wants to merge 1 commit into
base: master
from
Open

Conversation

@Athameon
Copy link

@Athameon Athameon commented Nov 26, 2020

If a BarChart has no printed values, the method entry.getRanges() returns null and the method ranges.length throws an exception (null.length).
This can simply be prevented by asking the ranges to be not null before asking for length.

PR Checklist:

  • I have tested this extensively and it does not break any existing behavior.
  • I have added/updated examples and tests for any new behavior.
  • If this is a significant change, an issue has already been created where the problem / solution was discussed: [https://github.com//issues/5054]

PR Description

Check array to be not null before accessing a property of null.

The BarChart does not crash if it has empty values.

It prevents a crash of the app.

If a BarChart has no printed values, the method entry.getRanges() returns null and the method ranges.length throws an exception (null.length).
This can simply be prevented by asking the ranges to be not null before asking for length.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Linked issues

Successfully merging this pull request may close these issues.

None yet

1 participant
You can’t perform that action at this time.