Protect TimelineItemAspectRatioBox against Float.NaN (#1201)

* Protect `TimelineItemAspectRatioBox` against infinite values.
This commit is contained in:
Jorge Martin Espinosa 2023-08-31 12:58:37 +02:00 committed by GitHub
parent c0a4ca16a2
commit 47a0ecb3b8
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
2 changed files with 4 additions and 1 deletions

1
changelog.d/1995.bugfix Normal file
View file

@ -0,0 +1 @@
Crash with `aspectRatio` modifier when `Float.NaN` was used as input.

View file

@ -132,10 +132,12 @@ class TimelineItemContentMessageFactory @Inject constructor(
}
private fun aspectRatioOf(width: Long?, height: Long?): Float? {
return if (height != null && width != null) {
val result = if (height != null && width != null) {
width.toFloat() / height.toFloat()
} else {
null
}
return result?.takeIf { it.isFinite() }
}
}