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
2 changed files with 4 additions and 1 deletions
+1
View File
@@ -0,0 +1 @@
Crash with `aspectRatio` modifier when `Float.NaN` was used as input.
@@ -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() }
}
}