Skip to content

Commit

Permalink
Prevent crashes when computing aspect ratios on zero media width or h…
Browse files Browse the repository at this point in the history
…eight
  • Loading branch information
stefanceriu committed Feb 8, 2024
1 parent 1304f67 commit b4b9224
Showing 1 changed file with 3 additions and 3 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -134,7 +134,7 @@ struct RoomTimelineItemFactory: RoomTimelineItemFactoryProtocol {
var aspectRatio: CGFloat?
let width = imageInfo.width.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
}

Expand Down Expand Up @@ -488,7 +488,7 @@ struct RoomTimelineItemFactory: RoomTimelineItemFactoryProtocol {
let height = messageContent.info?.height.map(CGFloat.init)

var aspectRatio: CGFloat?
if let width, let height {
if let width, let height, width > 0, height > 0 {
aspectRatio = width / height
}

Expand All @@ -508,7 +508,7 @@ struct RoomTimelineItemFactory: RoomTimelineItemFactoryProtocol {
let height = messageContent.info?.height.map(CGFloat.init)

var aspectRatio: CGFloat?
if let width, let height {
if let width, let height, width > 0, height > 0 {
aspectRatio = width / height
}

Expand Down

0 comments on commit b4b9224

Please sign in to comment.