Fixes issue #94521: Make sure to always specify Uint32Array length #94529
+28
−2
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
This PR fixes #94521 for the 1.44 release.
When the
decodeSemanticTokensDto
was called, it was possible that it was called with aVSBuffer
that uses aUint8Array
which is misaligned on a backingArrayBuffer
. Think about a large data blob (a message from the ext host) and only a portion of it is the encoded semantic tokens dto.The code handled the misaligned case before (see the check
uint8Arr.byteOffset % 4 === 0
), but the handling was incomplete because a length was not passed to the Uint32Array ctor. When the length is not passed in, the Uint32Array will try to use theArrayBuffer.byteLength / 4
, but that might be beyond the length of the passed inVSBuffer
into memory of the backingArrayBuffer
, which might not be a multiple of 4.The unit tests show this case clearly, but unfortunately there are no steps given this has to do with the way in which the extension host can end up serializing a batch of messages into a single blob...