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

ToArray fails when buffer capacity is larger than its length. #1805

Merged
merged 3 commits into from
Oct 1, 2024

Conversation

jlaanstra
Copy link
Collaborator

@jlaanstra jlaanstra commented Sep 30, 2024

Introduced in #1541

Workaround:

if (WindowsRuntimeMarshal.TryGetDataUnsafe(buffer, out var data))
{
    Span<byte> bufferAsSpan = new Span<byte>(data.ToPointer(), (int)buffer.Length);
    return bufferAsSpan.ToArray();
}

@jlaanstra jlaanstra changed the title Add failing test for ToArray. ToArray fails when buffer capacity is larger than its length. Sep 30, 2024
@manodasanW manodasanW merged commit 2e56fca into microsoft:master Oct 1, 2024
1 check passed
@jlaanstra jlaanstra deleted the user/jlaans/toarray branch October 1, 2024 18:14
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

Successfully merging this pull request may close these issues.

3 participants