Skip to content

Commit 5865b94

Browse files
committed
Improved stability with incorrect Bulk data
Days Gone has some textures with bulk data at the end of uasset file, however data itself is nearly empty. Discarding such bunk data instead of crashing with serializing after the end of file.
1 parent 61ba5e5 commit 5865b94

File tree

1 file changed

+8
-1
lines changed

1 file changed

+8
-1
lines changed

Unreal/UnCoreSerialize.cpp

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1234,7 +1234,7 @@ void FByteBulkData::Serialize(FArchive &Ar)
12341234

12351235
SerializeHeader(Ar);
12361236

1237-
if (BulkDataFlags & BULKDATA_Unused) // skip serializing
1237+
if (BulkDataFlags & BULKDATA_Unused || ElementCount == 0) // skip serializing
12381238
{
12391239
#if DEBUG_BULK
12401240
appPrintf("bulk with no data\n");
@@ -1258,6 +1258,13 @@ void FByteBulkData::Serialize(FArchive &Ar)
12581258
}
12591259
if (BulkDataFlags & BULKDATA_PayloadAtEndOfFile)
12601260
{
1261+
if (BulkDataOffsetInFile + 16 >= Ar.GetFileSize64())
1262+
{
1263+
appNotify("Bulk position is outside of the file (%d bytes)", BulkDataSizeOnDisk);
1264+
// Prevent any possible use of this bulk
1265+
BulkDataFlags |= BULKDATA_Unused;
1266+
return;
1267+
}
12611268
// stored in the same file, but at different position
12621269
// save archive position
12631270
int savePos, saveStopper;

0 commit comments

Comments
 (0)