Ensure enough data available while disassembling

This commit is contained in:
user4520 2021-10-17 13:35:03 +02:00 committed by Xenxo Espasandín
parent 1d32f27680
commit a015ab8708
2 changed files with 40 additions and 38 deletions

View File

@ -31,6 +31,7 @@
#include <fstream> #include <fstream>
#include <unordered_map> #include <unordered_map>
#include <stdio.h> #include <stdio.h>
#include <cassert>
// Ext // Ext
using namespace std::literals; using namespace std::literals;

View File

@ -71,6 +71,7 @@ void disassembler::dissasemble_function(const gsc::function_ptr& func)
func->instructions.push_back(std::make_unique<gsc::instruction>()); func->instructions.push_back(std::make_unique<gsc::instruction>());
auto& inst = func->instructions.back(); auto& inst = func->instructions.back();
inst->index = static_cast<std::uint32_t>(script_->pos()); inst->index = static_cast<std::uint32_t>(script_->pos());
assert(script_->is_avail());
inst->opcode = script_->read<std::uint8_t>(); inst->opcode = script_->read<std::uint8_t>();
inst->size = opcode_size(inst->opcode); inst->size = opcode_size(inst->opcode);