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 ++++ view/sharedcache/core/SharedCache.h | 2 +- 2 files changed, 5 insertions(+), 1 deletion(-) (limited to 'view/sharedcache') 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(); diff --git a/view/sharedcache/core/SharedCache.h b/view/sharedcache/core/SharedCache.h index 54c63bb3..f59cbb0f 100644 --- a/view/sharedcache/core/SharedCache.h +++ b/view/sharedcache/core/SharedCache.h @@ -482,7 +482,7 @@ namespace SharedCacheCore { .MSL(symtab), .MSL(dysymtab), .MSL(dyldInfo), - .MSL(routines64), // TODO: This supposedly caused a crash on some binary? Need a repro. + .MSL(routines64), .MSL(functionStarts), .MSL(moduleInitSections), .MSL(exportTrie), -- cgit v1.3.1