AutosoftDMS / SignalR-Swift

SignalR client library written in pure Swift
MIT License
60 stars 55 forks source link

Crash in ChunkBuffer #25

Closed perryhoekstra closed 6 years ago

perryhoekstra commented 6 years ago

In 2.0.1, I am seeing a crash in ChunkBuffer.swift

if let endIndex = lineEndIndex { buffer.removeSubrange(buffer.startIndex ..< endIndex) }

The error is:
Fatal error: replaceSubrange: subrange extends past String end

perryhoekstra commented 6 years ago

Maybe something like this:

if let endIndex = lineEndIndex { buffer.removeSubrange(buffer.startIndex ..< min(endIndex, buffer.endIndex)) }

vldalx commented 6 years ago

@perryhoekstra Could you provide either the content of buffer when the crash occurred or the string that you appended to ChunkBuffer before the crash?

perryhoekstra commented 6 years ago

@vldalx The buffer is an empty string

vldalx commented 6 years ago

@perryhoekstra I've figured out the reason for the crash. The fix is ready.