Skip to content

Commit

Permalink
Fix deletion of duplicate rpaths
Browse files Browse the repository at this point in the history
Deferring field population to the end seems to break rpath deletion of
duplicated rpaths.

Closes #356.
  • Loading branch information
carlocab committed May 14, 2021
1 parent 20419be commit 075b9b1
Showing 1 changed file with 2 additions and 5 deletions.
7 changes: 2 additions & 5 deletions lib/macho/macho_file.rb
Original file line number Diff line number Diff line change
Expand Up @@ -418,11 +418,8 @@ def delete_rpath(path, _options = {})
rpath_cmds = command(:LC_RPATH).select { |r| r.path.to_s == path }
raise RpathUnknownError, path if rpath_cmds.empty?

# delete the commands in reverse order, offset descending. this
# allows us to defer (expensive) field population until the very end
rpath_cmds.reverse_each { |cmd| delete_command(cmd, :repopulate => false) }

populate_fields
# delete the commands in reverse order, offset descending.
rpath_cmds.reverse_each { |cmd| delete_command(cmd) }
end

# Write all Mach-O data to the given filename.
Expand Down

0 comments on commit 075b9b1

Please sign in to comment.