Protect TimelineItemAspectRatioBox against Float.NaN (#1201)
* Protect `TimelineItemAspectRatioBox` against infinite values.
This commit is contained in:
parent
e7cf36e2f9
commit
1c4eb45a60
2 changed files with 4 additions and 1 deletions
1
changelog.d/1995.bugfix
Normal file
1
changelog.d/1995.bugfix
Normal 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? {
|
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()
|
width.toFloat() / height.toFloat()
|
||||||
} else {
|
} else {
|
||||||
null
|
null
|
||||||
}
|
}
|
||||||
|
|
||||||
|
return result?.takeIf { it.isFinite() }
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue