Skip to content

Commit

Permalink
Added fix for crash when no image in DG2
Browse files Browse the repository at this point in the history
  • Loading branch information
AndyQ committed Jun 14, 2022
1 parent d2a659b commit e059cf0
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 0 deletions.
1 change: 1 addition & 0 deletions CHANGELOG
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@ v2.0.0
Switched app over to user async/await - makes the code paths much simpler
Added fix for DG11 names - thanks @TerjeLon
Added fix for missing reader session invalidation - thanks @TerjeLon
Added fix for crash when there is no image in the DG2 - thanks @brkerturk

v1.1.9
Retrieves names from DG11 if present otherwise fall back to DG1 - thanks @TerjeLon
Expand Down
5 changes: 5 additions & 0 deletions Sources/NFCPassportReader/DataGroups/DataGroup2.swift
Original file line number Diff line number Diff line change
Expand Up @@ -153,6 +153,11 @@ func getImage() -> UIImage? {
let jpeg2000BitmapHeader : [UInt8] = [0x00,0x00,0x00,0x0c,0x6a,0x50,0x20,0x20,0x0d,0x0a]
let jpeg2000CodestreamBitmapHeader : [UInt8] = [0xff,0x4f,0xff,0x51]

if data.count < offset+jpeg2000CodestreamBitmapHeader.count {
throw NFCPassportReaderError.UnknownImageFormat
}


if [UInt8](data[offset..<offset+jpegHeader.count]) != jpegHeader &&
[UInt8](data[offset..<offset+jpeg2000BitmapHeader.count]) != jpeg2000BitmapHeader &&
[UInt8](data[offset..<offset+jpeg2000CodestreamBitmapHeader.count]) != jpeg2000CodestreamBitmapHeader {
Expand Down

0 comments on commit e059cf0

Please sign in to comment.