Skip to content

Commit

Permalink
LibCpp2IL: Return empty array if number of read elements is 0 (#345)
Browse files Browse the repository at this point in the history
Co-authored-by: commonuserlol <commonuserlol@users.noreply.github.com>
  • Loading branch information
commonuserlol and commonuserlol authored Sep 29, 2024
1 parent 2f8e5b3 commit 0fc6a65
Showing 1 changed file with 4 additions and 0 deletions.
4 changes: 4 additions & 0 deletions LibCpp2IL/Metadata/Il2CppMetadata.cs
Original file line number Diff line number Diff line change
Expand Up @@ -314,6 +314,10 @@ private Il2CppMetadata(MemoryStream stream) : base(stream)
//Now we can work out how many elements there are.
var numElements = length / elementSize;

if (numElements == 0) {
return [];
}

//And so we can allocate an array of that length, and assign the first element.
var arr = new T[numElements];
arr[0] = first;
Expand Down

0 comments on commit 0fc6a65

Please sign in to comment.