Skip to content

Commit a39f439

Browse files
ds5678SamboyCoding
authored andcommitted
Initialize arrays as empty when count is zero
Ensure _codeGenModuleMethodPointers, _codegenModuleRgctxRanges, and _codegenModuleRgctxs are always initialized, even when their respective counts are zero, by assigning empty arrays. This prevents potential null reference issues.
1 parent b597d64 commit a39f439

File tree

1 file changed

+12
-0
lines changed

1 file changed

+12
-0
lines changed

LibCpp2IL/Il2CppBinary.cs

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -197,6 +197,10 @@ public void Init(ulong pCodeRegistration, ulong pMetadataRegistration, Il2CppMet
197197
_codeGenModuleMethodPointers[i] = new ulong[codeGenModule.methodPointerCount];
198198
}
199199
}
200+
else
201+
{
202+
_codeGenModuleMethodPointers[i] = [];
203+
}
200204

201205
if (codeGenModule.rgctxRangesCount > 0)
202206
{
@@ -212,6 +216,10 @@ public void Init(ulong pCodeRegistration, ulong pMetadataRegistration, Il2CppMet
212216
_codegenModuleRgctxRanges[i] = new Il2CppTokenRangePair[codeGenModule.rgctxRangesCount];
213217
}
214218
}
219+
else
220+
{
221+
_codegenModuleRgctxRanges[i] = [];
222+
}
215223

216224
if (codeGenModule.rgctxsCount > 0)
217225
{
@@ -227,6 +235,10 @@ public void Init(ulong pCodeRegistration, ulong pMetadataRegistration, Il2CppMet
227235
_codegenModuleRgctxs[i] = new Il2CppRGCTXDefinition[codeGenModule.rgctxsCount];
228236
}
229237
}
238+
else
239+
{
240+
_codegenModuleRgctxs[i] = [];
241+
}
230242
}
231243

232244
LibLogger.VerboseNewline($"\tOK ({(DateTime.Now - start).TotalMilliseconds} ms)");

0 commit comments

Comments
 (0)