-
-
Notifications
You must be signed in to change notification settings - Fork 6k
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
[Crash] Renderers (isDrawingValuesAllowed func) crash - wrong data type cast causes host app to crash #5197
Comments
I opened up a PR for this issue here: #5198 |
I have same problem when I upgrade the lib to 5.1. |
For my case , it happen when input empty data with setVisibleXRange
` |
@ffchung it seems like the pr got approved, but it's not merged in yet. please check the page of the pr. in the meanwhile feel free to use my custom fork. thank you 😄 |
@sorinmiroiu97 I just tested with the pr and it work for my case. Thanks. |
@ffchung so great to hear that buddy! thanks as well! 😄 |
@sorinmiroiu97 I think you have something wrong on Source/Charts/Renderers/HorizontalBarChartRenderer.swift |
@ffchung thanks a lot for pointing that out! i think i might have hit enter on the autocomplete and i didn't notice the X instead of Y. gonna fix it now! many thanks bud! |
What did you do?
We integrated the latest version of this library, as of the current time I'm writing this (v5.1.0), into our project for displaying some charts. There's an unusual behaviour, but a valid one in the project, that causes the app to crash because of a data cast from Double.infinite to Integer, but the this cast fails as infinite cannot be cast into an Int, and this code resides within the library.
The class in questions is
BarLineScatterCandleBubbleRenderer
and this is the place where it crashes:open func isDrawingValuesAllowed(dataProvider: ChartDataProvider?) -> Bool { guard let data = dataProvider?.data else { return false } return data.entryCount < Int(CGFloat(dataProvider?.maxVisibleCount ?? 0) * viewPortHandler.scaleX) }
What did you expect to happen?
I would've expected for this CGFloat to be checked against
CGFloat.infinity
andCGFloat.nan
and to return with a false in these cases out of theisDrawingValuesAllowed
function.Also I'd expect this check to be applied to all renderers as it can occur in the other files as well.
What happened instead?
The type cast fails and thus it crashes the host app.
DGCharts Environment
**DGCharts version/Branch/Commit Number:5.1.0
**Xcode version:Version 15.4 (15F31d)
**Swift version:5
**Platform(s) running DGCharts:iOS
**macOS version running Xcode:14.5 (23F79)
Demo Project
I'm not adding a demo project as I'm submitting a pull request so i need this ticket created in order to link the PR to this issue.
The text was updated successfully, but these errors were encountered: