summaryrefslogtreecommitdiff
path: root/view/sharedcache
diff options
context:
space:
mode:
authorMason Reed <mason@vector35.com>2025-02-11 22:09:59 -0500
committerMason Reed <mason@vector35.com>2025-02-12 18:43:02 -0500
commit1cec22a86f7a844595266ccd6fcad9e79a914f26 (patch)
tree85ec5f6cd8eab15095d852ff1fc1793a024a9660 /view/sharedcache
parentc5edc003b1c0667c936c2ba3a278821da28c3b42 (diff)
[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.
Diffstat (limited to 'view/sharedcache')
-rw-r--r--view/sharedcache/core/MetadataSerializable.cpp4
-rw-r--r--view/sharedcache/core/SharedCache.h2
2 files changed, 5 insertions, 1 deletions
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),