Skip to content

Commit

Permalink
~ CEnum: fix crash if name index is out of range
Browse files Browse the repository at this point in the history
  • Loading branch information
nikich340 committed Dec 19, 2022
1 parent 725739d commit 85c9d62
Showing 1 changed file with 6 additions and 3 deletions.
9 changes: 6 additions & 3 deletions WolvenKit.CR2W/Types/Primitive/NetPrimitive/CEnum.cs
Original file line number Diff line number Diff line change
Expand Up @@ -85,7 +85,7 @@ public override void Read(BinaryReader file, uint size)
while (true)
{
var idx = file.ReadUInt16();
if (idx == 0)
if (idx <= 0 || idx >= cr2w.names.Count)
break;

string s = cr2w.names[idx].Str;
Expand All @@ -97,9 +97,12 @@ public override void Read(BinaryReader file, uint size)
{
var idx = file.ReadUInt16();

string s = cr2w.names[idx].Str;
if (idx < cr2w.names.Count && idx >= 0)
{
string s = cr2w.names[idx].Str;

strings.Add(s);
strings.Add(s);
}
}

SetValue(strings);
Expand Down

0 comments on commit 85c9d62

Please sign in to comment.