File tree Expand file tree Collapse file tree 2 files changed +14
-2
lines changed Expand file tree Collapse file tree 2 files changed +14
-2
lines changed Original file line number Diff line number Diff line change @@ -19,10 +19,10 @@ internal class CBORParser {
1919 guard !data. isEmpty else { return nil }
2020
2121 var storage = Storage ( )
22- var index : Int = 0
22+ var index : Int = data . startIndex
2323
2424 do {
25- while index < data. count {
25+ while index < data. endIndex {
2626 let majorType = CBOR . majorType ( for: data [ index] )
2727
2828 switch majorType {
Original file line number Diff line number Diff line change @@ -1074,6 +1074,18 @@ class CBORParserTests: XCTestCase {
10741074
10751075 XCTAssertThrowsError ( try CBORParser . testCreateCodingKey ( from: UInt64 . max) )
10761076 }
1077+
1078+ func testSlicedDataInput( ) {
1079+ var value : Any !
1080+
1081+ // Skip over the first 2 bytes with a slice.
1082+ let data = convertFromHexString ( " 0x000000 " ) [ 2 ... ]
1083+
1084+ XCTAssertNoThrow ( value = try CBORParser . parse ( data) )
1085+ XCTAssertTrue ( value is UInt64 )
1086+ XCTAssertEqual ( value as! UInt64 , 0 )
1087+
1088+ }
10771089
10781090 // MARK: Private Methods
10791091
You can’t perform that action at this time.
0 commit comments