mirror of
https://github.com/Novaloop-AG/element-x-android.git
synced 2026-11-03 06:01:40 +00:00
Protect TimelineItemAspectRatioBox against Float.NaN (#1201)
* Protect `TimelineItemAspectRatioBox` against infinite values.
This commit is contained in:
committed by
GitHub
parent
c0a4ca16a2
commit
47a0ecb3b8
@@ -0,0 +1 @@
|
|||||||
|
Crash with `aspectRatio` modifier when `Float.NaN` was used as input.
|
||||||
+3
-1
@@ -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() }
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user