···55First build the package in release mode with the fuzzer and address checkers on:
6677```bash
88-swift build -c release --sanitize fuzzer,address
88+swift build -c release --sanitize fuzzer
99```
10101111Then run it:
+50
Sources/CBOR/Decoder/CBORDecoder.swift
···6868 }
6969 }
70707171+ /// Decodes multiple instances of the given type from CBOR binary data.
7272+ ///
7373+ /// Some BLOBs are made up of multiple CBOR-encoded datas concatenated without valid CBOR dividers (eg in an array
7474+ /// container). This method decodes that kind of data. It will attempt to decode an instance of the given type,
7575+ /// once done, if there's more data, it will continue to attempt to decode more instances.
7676+ ///
7777+ /// - Parameters:
7878+ /// - type: The decodable type to deserialize.
7979+ /// - data: The CBOR data to decode from.
8080+ /// - Returns: An instance of the decoded type.
8181+ /// - Throws: A ``DecodingError`` with context and a debug description for a failed deserialization operation.
8282+ public func decodeMultiple<T: Decodable>(_ type: T.Type, from data: Data) throws -> [T] {
8383+ do {
8484+ return try data.withUnsafeBytes {
8585+ let data = $0[...]
8686+ let reader = DataReader(data: data)
8787+ let scanner = CBORScanner(data: reader, options: options)
8888+ let results = try scanner.scan()
8989+9090+ guard !results.isEmpty else {
9191+ throw ScanError.unexpectedEndOfData
9292+ }
9393+9494+ let context = DecodingContext(options: options, results: results)
9595+ var nextRegion: DataRegion? = results.load(at: 0)
9696+9797+ var accumulator: [T] = []
9898+9999+ while let region = nextRegion {
100100+ let value = try SingleValueCBORDecodingContainer(context: context, data: region).decode(T.self)
101101+ accumulator.append(value)
102102+ let nextMapIndex = results.siblingIndex(region.mapOffset)
103103+ if nextMapIndex < results.count {
104104+ nextRegion = results.load(at: results.siblingIndex(region.mapOffset))
105105+ } else {
106106+ nextRegion = nil
107107+ }
108108+ }
109109+110110+ return accumulator
111111+ }
112112+ } catch {
113113+ if let error = error as? ScanError {
114114+ try throwScanError(error)
115115+ } else {
116116+ throw error
117117+ }
118118+ }
119119+ }
120120+71121 private func throwScanError(_ error: ScanError) throws -> Never {
72122 switch error {
73123 case .unexpectedEndOfData: