Skip to content

fix: FastBufferReader offset with the default length (up-port) - #4222

Merged
EmandM merged 3 commits into
develop-3.x.xfrom
fix/fastbufferreader-offset-default-length-up-port
Oct 28, 2026
Merged

EmandM merged 3 commits into
develop-3.x.xfrom
fix/fastbufferreader-offset-default-length-up-port

Conversation

@NoelStephensUnity

Copy link
Copy Markdown
Member

Purpose of this PR

Up-port of #4221.

A FastBufferReader created with an offset and the default length of -1 now reads exactly the bytes from the offset to the end of the source, instead of reporting offset extra bytes and copying them from past the end of the source. The ArraySegment<byte> overload that takes an offset now applies it from the start of the segment.

Jira ticket

UUM-158591

Changelog

  • Fixed: Issue where a FastBufferReader created with an offset and the default length of -1 read past the end of its source. The ArraySegment<byte> overload that takes an offset now applies it from the start of the segment.

Documentation

  • Includes edits to existing public API documentation.

Testing & QA (How your changes can be verified during release Playtest)

Functional Testing

Manual testing :

  • Manual testing done

Automated tests:

  • Covered by existing automated tests
  • Covered by new automated tests

Does the change require QA team to:

  • Review automated tests?
  • Execute manual tests?
  • Provide feedback about the PR?

Up-port

N/A (this is the up-port)

Backports

#4221

A FastBufferReader created by copying a source with an offset and length -1 took
the whole source length as its length, so it reported offset bytes too many and
copied them from past the end of the source. Length -1 now means every byte after
the offset when copying; Allocator.None, which reads the source in place starting
at the offset, keeps the whole source length as before.

The ArraySegment<byte> overload that takes an offset now applies it from the start
of the segment instead of the start of the underlying array.

UUM-158591

@u-pr u-pr Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

💡 Harness Review

Ship it

The change correctly limits offset copies to the remaining source bytes and makes explicit ArraySegment offsets segment-relative. I examined constructor semantics, affected callers, regression tests, and release notes; no actionable issues were found.

Reviewed commit 5c2f8d0

🤖 Helpful? 👍/👎

@codecov-github-com

codecov-github-com Bot commented Oct 27, 2026 •

Copy link
Copy Markdown

Codecov Report

All modified and coverable lines are covered by tests ✅

@@                Coverage Diff                @@
##           develop-3.x.x    #4222      +/-   ##
=================================================
- Coverage          76.25%   76.20%   -0.06%     
=================================================
  Files                159      159              
  Lines              27538    27576      +38     
=================================================
+ Hits               21000    21013      +13     
- Misses              6538     6563      +25     
Flag Coverage Δ
NGOv2_project_testproject_ubuntu 75.27% <100.00%> (-0.06%) ⬇️

Flags with carried forward coverage won't be shown. Click here to find out more.

Files with missing lines Coverage Δ
...eobjects/Runtime/Serialization/FastBufferReader.cs 81.53% <100.00%> (+1.49%) ⬆️
Components Coverage Δ
com.unity.netcode.gameobjects 76.20% <16.66%> (-0.06%) ⬇️

ℹ️ Need help interpreting these results?

@EmandM
EmandM enabled auto-merge (squash) October 28, 2026 15:52
@EmandM
EmandM merged commit 37e00de into develop-3.x.x Oct 28, 2026
27 checks passed
@EmandM
EmandM deleted the fix/fastbufferreader-offset-default-length-up-port branch October 28, 2026 18:34
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.

4 participants