Kernel: Don't crash when writing a coredump with an unnamed region

Previously we'd try to call ByteBuffer::append(nullptr, 1) when we
came across a VM region that had no name.
This commit is contained in:
Gunnar Beutner 2021-05-28 16:13:47 +02:00 committed by Andreas Kling
parent fd6b04055c
commit 9adcfd5726
Notes: sideshowbarker 2024-07-18 17:16:16 +09:00

View File

@ -246,7 +246,9 @@ ByteBuffer CoreDump::create_notes_regions_data() const
memory_region_info_buffer.append((void*)&info, sizeof(info));
// NOTE: The region name *is* null-terminated, so the following is ok:
memory_region_info_buffer.append(region->name().characters_without_null_termination(), region->name().length() + 1);
auto name = region->name();
if (!name.is_null())
memory_region_info_buffer.append(name.characters_without_null_termination(), name.length() + 1);
regions_data += memory_region_info_buffer;
}