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

Fixes index out of range crash. #2167

Merged
merged 1 commit into from
Feb 15, 2017
Merged

Fixes index out of range crash. #2167

merged 1 commit into from
Feb 15, 2017

Conversation

kzaher
Copy link
Contributor

@kzaher kzaher commented Feb 15, 2017

This crashed in prod for us.

@pmairoldi
Copy link
Collaborator

Thanks. The failing ci is because realm is taking too long to build. I'll merge this.

@pmairoldi pmairoldi merged commit 0148058 into ChartsOrg:master Feb 15, 2017
@danielgindi
Copy link
Collaborator

Actually, the docs of this function says very clearly that it throws an exception if out of bounds. Why did you run into this in the first place? The caller code should check the bounds

@kzaher
Copy link
Contributor Author

kzaher commented Feb 22, 2017

@danielgindi Swift throwing mechanism is different then Java's.

If this was intended behavior, then the prototype should have been:

open override func entryForIndex(_ i: Int) throws -> ChartDataEntry

or if you wanted fatal error:

open override func entryForIndex(_ i: Int) -> ChartDataEntry

screen shot 2017-02-22 at 21 06 00

@danielgindi
Copy link
Collaborator

Yes, I agree that it should be declared as throws.

But I'm trying here to understand the situation, not the syntax...
How did you end up getting a fatal error? Did you manually call the function with an invalid argument, updated the chart with invalid data, or did the chart fail and did something wrong?

@kzaher kzaher deleted the fix branch March 4, 2017 15:31
@nikwest
Copy link

nikwest commented Mar 7, 2017

I ran into the same problem. I created an empty LineChartDataSet. This will crash once the view is displayed.
It might be the problem that
stride(from:through:by:)
should be replaced by
stride(from:to:by:)
in LineChartRenderer -> drawLinear(..) Line 332
(just a guess)

PeterSrost pushed a commit to sokol8/Charts that referenced this pull request Oct 31, 2018
Fixes index out of range crash.
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.

4 participants