1
0
Fork 0
mirror of https://github.com/beefytech/Beef.git synced 2025-06-14 14:24:10 +02:00

IndexRange protection fix

This commit is contained in:
Brian Fiete 2021-10-24 09:00:24 -07:00
parent 1fd19c7672
commit 14794e5574
3 changed files with 11 additions and 11 deletions

View file

@ -217,9 +217,9 @@ namespace System
struct IndexRange : RangeExpression struct IndexRange : RangeExpression
{ {
public Index mStart; protected Index mStart;
public Index mEnd; protected Index mEnd;
public bool mIsClosed; protected bool mIsClosed;
public this() public this()
{ {

View file

@ -177,7 +177,7 @@ namespace System
get get
{ {
T* start; T* start;
switch (range.mStart) switch (range.[Friend]mStart)
{ {
case .FromFront(let offset): case .FromFront(let offset):
Debug.Assert((uint)offset <= (uint)mLength); Debug.Assert((uint)offset <= (uint)mLength);
@ -187,9 +187,9 @@ namespace System
start = mPtr + mLength - 1 - offset; start = mPtr + mLength - 1 - offset;
} }
T* end; T* end;
if (range.mIsClosed) if (range.[Friend]mIsClosed)
{ {
switch (range.mEnd) switch (range.[Friend]mEnd)
{ {
case .FromFront(let offset): case .FromFront(let offset):
Debug.Assert((uint)offset < (uint)mLength); Debug.Assert((uint)offset < (uint)mLength);
@ -201,7 +201,7 @@ namespace System
} }
else else
{ {
switch (range.mEnd) switch (range.[Friend]mEnd)
{ {
case .FromFront(let offset): case .FromFront(let offset):
Debug.Assert((uint)offset <= (uint)mLength); Debug.Assert((uint)offset <= (uint)mLength);

View file

@ -3021,7 +3021,7 @@ namespace System
get get
{ {
char8* start; char8* start;
switch (range.mStart) switch (range.[Friend]mStart)
{ {
case .FromFront(let offset): case .FromFront(let offset):
Debug.Assert((uint)offset <= (uint)mLength); Debug.Assert((uint)offset <= (uint)mLength);
@ -3031,9 +3031,9 @@ namespace System
start = mPtr + mLength - 1 - offset; start = mPtr + mLength - 1 - offset;
} }
char8* end; char8* end;
if (range.mIsClosed) if (range.[Friend]mIsClosed)
{ {
switch (range.mEnd) switch (range.[Friend]mEnd)
{ {
case .FromFront(let offset): case .FromFront(let offset):
Debug.Assert((uint)offset < (uint)mLength); Debug.Assert((uint)offset < (uint)mLength);
@ -3045,7 +3045,7 @@ namespace System
} }
else else
{ {
switch (range.mEnd) switch (range.[Friend]mEnd)
{ {
case .FromFront(let offset): case .FromFront(let offset):
Debug.Assert((uint)offset <= (uint)mLength); Debug.Assert((uint)offset <= (uint)mLength);