Skip to content

Commit

Permalink
- do not abort saving and loading on pointer serialization errors
Browse files Browse the repository at this point in the history
Attempt to serialize invalid pointer is reported, and its value is treated as null
  • Loading branch information
alexey-lysiuk committed Sep 2, 2020
1 parent 58f5c03 commit adfd5de
Showing 1 changed file with 12 additions and 3 deletions.
15 changes: 12 additions & 3 deletions src/common/engine/serializer_internal.h
Expand Up @@ -237,13 +237,19 @@ FSerializer &SerializePointer(FSerializer &arc, const char *key, T *&value, T **
{
vv = value - base;
if (vv < 0 || vv >= count)
I_Error("Trying to serialize out-of-bounds array value with key '%s', index = %lli, size = %lli", key, vv, count);
{
Printf("Trying to serialize out-of-bounds array value with key '%s', index = %lli, size = %lli\n", key, vv, count);
vv = -1;
}
}
Serialize(arc, key, vv, nullptr);
if (vv == -1)
value = nullptr;
else if (vv < 0 || vv >= count)
I_Error("Trying to serialize out-of-bounds array value with key '%s', index = %lli, size = %lli", key, vv, count);
{
Printf("Trying to serialize out-of-bounds array value with key '%s', index = %lli, size = %lli\n", key, vv, count);
value = nullptr;
}
else
value = base + vv;
}
Expand All @@ -254,7 +260,10 @@ template<class T>
FSerializer &SerializePointer(FSerializer &arc, const char *key, T *&value, T **defval, TArray<T> &array)
{
if (array.Size() == 0)
I_Error("Trying to serialize a value with key '%s' from empty array", key);
{
Printf("Trying to serialize a value with key '%s' from empty array\n", key);
return arc;
}
return SerializePointer(arc, key, value, defval, array.Data(), array.Size());
}

0 comments on commit adfd5de

Please sign in to comment.