Skip to content

ArrayBufferWriter double grow boundary fix#124470

Merged
jkotas merged 1 commit intodotnet:mainfrom
sstronin:fix/arraybufferwriter-unexpected-out-of-memory
Feb 16, 2026
Merged

ArrayBufferWriter double grow boundary fix#124470
jkotas merged 1 commit intodotnet:mainfrom
sstronin:fix/arraybufferwriter-unexpected-out-of-memory

Conversation

@sstronin
Copy link
Contributor

ArrayBufferWriter unexpectedly fails to reallocate if current length is int.MaxValue/2, e.g.:

var abw = new ArrayBufferWriter(int.MaxValue / 2);
abw.Advance(abw.Capacity);
abw.GetMemory(1); // throws

Unfortunately it's hard to write a test because the result will be OutOfMemoryException, same as if there is just not enough memory.

Found by Linux Verification Center (linuxtesting.org).

@dotnet-policy-service dotnet-policy-service bot added the community-contribution Indicates that the PR has been added by a community member label Feb 16, 2026
@dotnet-policy-service
Copy link
Contributor

Tagging subscribers to this area: @dotnet/area-system-buffers
See info in area-owners.md if you want to be subscribed.

@jkotas
Copy link
Member

jkotas commented Feb 16, 2026

/ba-g infra timeout

@jkotas jkotas merged commit 95b3ea0 into dotnet:main Feb 16, 2026
91 of 94 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

area-System.Buffers community-contribution Indicates that the PR has been added by a community member

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants