NLayer icon indicating copy to clipboard operation
NLayer copied to clipboard

MpegStreamReader Buffer resize/move logic issue

Open mdsitton opened this issue 1 year ago • 0 comments

https://github.com/naudio/NLayer/blob/670d408e6c2b9b0730f20316edc726db138c806e/NLayer/Decoder/MpegStreamReader.cs#L403

This loop trying to do this backward move operation on the buffer is extremely extremely busted.

Not only does this never run because in this context moveCount should be negative. where i is always greater than 0 so the first loop iteration the check will fail. But destIdx = Data.Length - 1 - moveCount increases the destination index past the end of the array so if this does run it would result in an exception.

I don't really understand the original intent with this code enough to submit a PR so issue it is.

mdsitton avatar May 04 '24 13:05 mdsitton