diff options
-rw-r--r-- | courgette/assembly_program.cc | 1 | ||||
-rw-r--r-- | courgette/disassembler_elf_32.cc | 12 |
2 files changed, 7 insertions, 6 deletions
diff --git a/courgette/assembly_program.cc b/courgette/assembly_program.cc index f577b98..021de59 100644 --- a/courgette/assembly_program.cc +++ b/courgette/assembly_program.cc @@ -422,6 +422,7 @@ EncodedProgram* AssemblyProgram::Encode() const { const uint8* byte_values = static_cast<BytesInstruction*>(instruction)->byte_values(); uint32 len = static_cast<BytesInstruction*>(instruction)->len(); + if (!encoded->AddCopy(len, byte_values)) return NULL; break; diff --git a/courgette/disassembler_elf_32.cc b/courgette/disassembler_elf_32.cc index fc4c379..bfd1ef4 100644 --- a/courgette/disassembler_elf_32.cc +++ b/courgette/disassembler_elf_32.cc @@ -409,13 +409,13 @@ CheckBool DisassemblerElf32::ParseSimpleRegion( const uint8* start = OffsetToPointer(start_file_offset); const uint8* end = OffsetToPointer(end_file_offset); - const uint8* p = start; + // Callers don't guarantee start < end + if (start >= end) return true; - while (p < end) { - if (!program->EmitByteInstruction(*p)) - return false; - ++p; - } + const ptrdiff_t len = end - start; // Works because vars are byte pointers + + if (!program->EmitBytesInstruction(start, len)) + return false; return true; } |