Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

MpegStreamReader Buffer resize/move logic issue #38

Open
mdsitton opened this issue May 4, 2024 · 0 comments
Open

MpegStreamReader Buffer resize/move logic issue #38

mdsitton opened this issue May 4, 2024 · 0 comments

Comments

@mdsitton
Copy link

mdsitton commented May 4, 2024

for (int i = 0, srcIdx = Data.Length - 1, destIdx = Data.Length - 1 - moveCount; i < moveCount; i++, srcIdx--, destIdx--)

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.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant