mirror of
https://github.com/ZDoom/gzdoom.git
synced 2024-11-22 20:21:26 +00:00
- do not abort saving and loading on pointer serialization errors
Attempt to serialize invalid pointer is reported, and its value is treated as null
This commit is contained in:
parent
58f5c030fe
commit
adfd5de166
1 changed files with 12 additions and 3 deletions
|
@ -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;
|
||||
}
|
||||
|
@ -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());
|
||||
}
|
||||
|
||||
|
|
Loading…
Reference in a new issue