Skip to content

MpegStreamReader Buffer resize/move logic issue #38

Open
@mdsitton

Description

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.

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions