Skip to content

Commit c296ca3

Browse files
AnthonyMDevgh-action-runner
authored andcommitted
Fix infinite loop in invalid multipart response parsing. (apollographql/apollo-ios-dev#839)
1 parent bdb9db0 commit c296ca3

File tree

1 file changed

+2
-1
lines changed

1 file changed

+2
-1
lines changed

Sources/Apollo/ResponseParsing/MultipartResponseSpecificationParser.swift

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -36,14 +36,15 @@ enum MultipartResponseParsing {
3636

3737

3838
struct DataLineIterator: IteratorProtocol {
39-
/// A double carriage return. Used as the seperator between data lines within a multipart response chunk
39+
/// A double carriage return. Used as the separator between data lines within a multipart response chunk
4040
private static let DataLineSeparator: Data = CRLF + CRLF // "\r\n\r\n"
4141

4242
var data: Data
4343

4444
mutating func next() -> Data? {
4545
guard !data.isEmpty else { return nil }
4646
guard let separatorRange = data.firstRange(of: Self.DataLineSeparator) else {
47+
defer { data = Data() }
4748
return data
4849
}
4950

0 commit comments

Comments
 (0)