mirror of
https://github.com/Novaloop-AG/element-x-ios.git
synced 2026-11-03 16:10:20 +00:00
Prevent crashes when computing aspect ratios on zero media width or height
This commit is contained in:
@@ -134,7 +134,7 @@ struct RoomTimelineItemFactory: RoomTimelineItemFactoryProtocol {
|
|||||||
var aspectRatio: CGFloat?
|
var aspectRatio: CGFloat?
|
||||||
let width = imageInfo.width.map(CGFloat.init)
|
let width = imageInfo.width.map(CGFloat.init)
|
||||||
let height = imageInfo.height.map(CGFloat.init)
|
let height = imageInfo.height.map(CGFloat.init)
|
||||||
if let width, let height {
|
if let width, let height, width > 0, height > 0 {
|
||||||
aspectRatio = width / height
|
aspectRatio = width / height
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -488,7 +488,7 @@ struct RoomTimelineItemFactory: RoomTimelineItemFactoryProtocol {
|
|||||||
let height = messageContent.info?.height.map(CGFloat.init)
|
let height = messageContent.info?.height.map(CGFloat.init)
|
||||||
|
|
||||||
var aspectRatio: CGFloat?
|
var aspectRatio: CGFloat?
|
||||||
if let width, let height {
|
if let width, let height, width > 0, height > 0 {
|
||||||
aspectRatio = width / height
|
aspectRatio = width / height
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -508,7 +508,7 @@ struct RoomTimelineItemFactory: RoomTimelineItemFactoryProtocol {
|
|||||||
let height = messageContent.info?.height.map(CGFloat.init)
|
let height = messageContent.info?.height.map(CGFloat.init)
|
||||||
|
|
||||||
var aspectRatio: CGFloat?
|
var aspectRatio: CGFloat?
|
||||||
if let width, let height {
|
if let width, let height, width > 0, height > 0 {
|
||||||
aspectRatio = width / height
|
aspectRatio = width / height
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -0,0 +1 @@
|
|||||||
|
Prevent crashes when computing aspect ratios on zero media width or height
|
||||||
Reference in New Issue
Block a user