Skip to content

Commit 1cec22a

Browse files
committed
[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.
1 parent c5edc00 commit 1cec22a

File tree

2 files changed

+5
-1
lines changed

2 files changed

+5
-1
lines changed

view/sharedcache/core/MetadataSerializable.cpp

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -354,6 +354,10 @@ void Serialize(SerializationContext& context, const routines_command_64& value)
354354
void Deserialize(DeserializationContext& context, std::string_view name, routines_command_64& b)
355355
{
356356
auto bArr = context.doc[name.data()].GetArray();
357+
// Because we might open databases that had not previously serialized this, we must allow
358+
// an empty array, otherwise we will crash!
359+
if (bArr.Size() < 4)
360+
return;
357361
b.cmd = bArr[0].GetUint();
358362
b.cmdsize = bArr[1].GetUint();
359363
b.init_address = bArr[2].GetUint();

view/sharedcache/core/SharedCache.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -482,7 +482,7 @@ namespace SharedCacheCore {
482482
.MSL(symtab),
483483
.MSL(dysymtab),
484484
.MSL(dyldInfo),
485-
.MSL(routines64), // TODO: This supposedly caused a crash on some binary? Need a repro.
485+
.MSL(routines64),
486486
.MSL(functionStarts),
487487
.MSL(moduleInitSections),
488488
.MSL(exportTrie),

0 commit comments

Comments
 (0)