Fixing buffer overrun in disasm.

This commit is contained in:
Ben Vanik 2015-08-17 20:38:37 -07:00
parent 4921c051a2
commit 59b9e9ceb0
1 changed files with 6 additions and 1 deletions

View File

@ -105,6 +105,9 @@ bool X64Assembler::Assemble(GuestFunction* function, HIRBuilder* builder,
void X64Assembler::DumpMachineCode(
void* machine_code, size_t code_size,
const std::vector<SourceMapEntry>& source_map, StringBuffer* str) {
if (source_map.empty()) {
return;
}
auto source_map_index = 0;
uint32_t next_code_offset = source_map[0].code_offset;
@ -123,7 +126,9 @@ void X64Assembler::DumpMachineCode(
auto& source_map_entry = source_map[source_map_index];
str->AppendFormat("%.8X ", source_map_entry.source_offset);
++source_map_index;
next_code_offset = source_map[source_map_index].code_offset;
next_code_offset = source_map_index < source_map.size()
? source_map[source_map_index].code_offset
: UINT_MAX;
} else {
str->Append(" ");
}