Skip to content

Commit

Permalink
Fix #781
Browse files Browse the repository at this point in the history
  • Loading branch information
romainthomas committed Sep 12, 2022
1 parent f29aa6b commit fde2c48
Showing 1 changed file with 10 additions and 2 deletions.
12 changes: 10 additions & 2 deletions src/MachO/BinaryParser.tcc
Original file line number Diff line number Diff line change
Expand Up @@ -887,16 +887,24 @@ ok_error_t BinaryParser::parse_load_commands() {
* with the BinaryParser constructor
*/
const size_t current_pos = stream_->pos();
if (!visited_.insert(cmd->fileoff).second) {
break;
}

stream_->setpos(cmd->fileoff);
BinaryParser bp;
bp.stream_ = std::move(stream_);
bp.config_ = config_;
bp.binary_ = std::unique_ptr<Binary>(new Binary{});
bp.stream_ = std::move(stream_);
bp.config_ = config_;
bp.visited_ = visited_;

if (!bp.init_and_parse()) {
LIEF_WARN("Parsing the Binary fileset raised error.");
}

stream_ = std::move(bp.stream_);
stream_->setpos(current_pos);
visited_ = std::move(bp.visited_);

if (bp.binary_ != nullptr) {
std::unique_ptr<Binary> filset_bin = std::move(bp.binary_);
Expand Down

0 comments on commit fde2c48

Please sign in to comment.