If the stream is closed before reaching the end-of-frame marker (n##n) and there is more chunks left then there is a condition where the chunkLeft is never updated resulting in a loop in Close().
This probably needs a deeper rethink but at very least if we reach the end-of-frame marker we should update the r.chunkLeft before returning the error to clean up and also make sure to record the bytes discarded.
If the stream is closed before reaching the end-of-frame marker (
n##n
) and there is more chunks left then there is a condition where the chunkLeft is never updated resulting in a loop in Close().This probably needs a deeper rethink but at very least if we reach the end-of-frame marker we should update the
r.chunkLeft
before returning the error to clean up and also make sure to record the bytes discarded.Thanks to @nights99 for reporting this
Fixes: #69