Commit cea578c
committed
fix(core): ArraySegment::CopyTo rejects a short destination (#2328, SR-AUD-055)
CopyTo(std::vector<T>&, index) RESIZED the destination whenever it was too
short. .NET's body is Array.Copy (ArraySegment.cs:106-110) and .NET arrays
cannot grow, so it raises ArgumentException(Arg_LongerThanDestArray).
Two independent reasons, both from the review. It diverged from .NET -- a caller
who passed the wrong buffer got a silently enlarged one instead of a diagnostic,
and a caller who sized a buffer deliberately had that size overwritten. And it
was THE ONE PLACE IN THE REPOSITORY THAT BROKE ITS OWN CONVENTION: twenty of the
twenty-six CopyTo(std::vector&, ...) overloads already rejected a short
destination.
The check is written out locally rather than shared, because
requireValidCopyDestination lives in Collections.Core and Core.Base must not
depend on it. The message is .NET's own, so the two cannot drift apart in
wording.
THE REVIEW'S PREMISE CORRECTION WAS RIGHT AND STILL INCOMPLETE. It found four
tests pinning the resize where the finding named one; there were five. The
fifth, NonDefaultSegmentsAreUnaffected, was found by the FULL GATE after a
filtered run had already passed -- which is exactly why the gate is run over the
whole repository rather than over the suites a change looks like it touches.
CopyTo_VectorWithOffset_ExpandsDest was named for the behaviour and is INVERTED
rather than patched. #2214 had deliberately preserved the resize while repairing
this file's default-state and overlap defects; that preservation was correct
then and is superseded now, and the comment saying so is updated rather than
deleted.
Three mutations, all caught. Gate 17,300 run, 0 failed.1 parent 7729e87 commit cea578c
7 files changed
Lines changed: 198 additions & 22 deletions
File tree
- audit
- docs
- modules/core
- include/System
- tests/System
Large diffs are not rendered by default.
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
66 | 66 | | |
67 | 67 | | |
68 | 68 | | |
69 | | - | |
| 69 | + | |
70 | 70 | | |
71 | 71 | | |
72 | 72 | | |
| |||
Lines changed: 85 additions & 0 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
| 1 | + | |
| 2 | + | |
| 3 | + | |
| 4 | + | |
| 5 | + | |
| 6 | + | |
| 7 | + | |
| 8 | + | |
| 9 | + | |
| 10 | + | |
| 11 | + | |
| 12 | + | |
| 13 | + | |
| 14 | + | |
| 15 | + | |
| 16 | + | |
| 17 | + | |
| 18 | + | |
| 19 | + | |
| 20 | + | |
| 21 | + | |
| 22 | + | |
| 23 | + | |
| 24 | + | |
| 25 | + | |
| 26 | + | |
| 27 | + | |
| 28 | + | |
| 29 | + | |
| 30 | + | |
| 31 | + | |
| 32 | + | |
| 33 | + | |
| 34 | + | |
| 35 | + | |
| 36 | + | |
| 37 | + | |
| 38 | + | |
| 39 | + | |
| 40 | + | |
| 41 | + | |
| 42 | + | |
| 43 | + | |
| 44 | + | |
| 45 | + | |
| 46 | + | |
| 47 | + | |
| 48 | + | |
| 49 | + | |
| 50 | + | |
| 51 | + | |
| 52 | + | |
| 53 | + | |
| 54 | + | |
| 55 | + | |
| 56 | + | |
| 57 | + | |
| 58 | + | |
| 59 | + | |
| 60 | + | |
| 61 | + | |
| 62 | + | |
| 63 | + | |
| 64 | + | |
| 65 | + | |
| 66 | + | |
| 67 | + | |
| 68 | + | |
| 69 | + | |
| 70 | + | |
| 71 | + | |
| 72 | + | |
| 73 | + | |
| 74 | + | |
| 75 | + | |
| 76 | + | |
| 77 | + | |
| 78 | + | |
| 79 | + | |
| 80 | + | |
| 81 | + | |
| 82 | + | |
| 83 | + | |
| 84 | + | |
| 85 | + | |
0 commit comments