From 1cec22a86f7a844595266ccd6fcad9e79a914f26 Mon Sep 17 00:00:00 2001 From: Mason Reed Date: Tue, 11 Feb 2025 22:09:59 -0500 Subject: [SharedCache] Fix crash when trying to deserialize a `routines_command_64` which had not been serialized. We will just return early, this is fine as the previous code would effectively do the same thing. --- view/sharedcache/core/MetadataSerializable.cpp | 4 ++++ 1 file changed, 4 insertions(+) (limited to 'view/sharedcache/core/MetadataSerializable.cpp') diff --git a/view/sharedcache/core/MetadataSerializable.cpp b/view/sharedcache/core/MetadataSerializable.cpp index ad8959f2..66a090c8 100644 --- a/view/sharedcache/core/MetadataSerializable.cpp +++ b/view/sharedcache/core/MetadataSerializable.cpp @@ -354,6 +354,10 @@ void Serialize(SerializationContext& context, const routines_command_64& value) void Deserialize(DeserializationContext& context, std::string_view name, routines_command_64& b) { auto bArr = context.doc[name.data()].GetArray(); + // Because we might open databases that had not previously serialized this, we must allow + // an empty array, otherwise we will crash! + if (bArr.Size() < 4) + return; b.cmd = bArr[0].GetUint(); b.cmdsize = bArr[1].GetUint(); b.init_address = bArr[2].GetUint(); -- cgit v1.3.1