Skip to content

Commit

Permalink
Don't hide ffi-inliner errors
Browse files Browse the repository at this point in the history
If ffi-inliner isn't installed the earlier lines of these methods will
raise an error and the Archive::Stat module won't be installed, so
Archive::Stat.ffi_libarchive_free_stat doens't exist and also raises an
error during the ensure block, hiding the originally-raised error.

Signed-off-by: Samuel Cochran <sj26@sj26.com>
  • Loading branch information
sj26 committed Aug 12, 2023
1 parent 7dd3c6b commit dae72e2
Showing 1 changed file with 14 additions and 10 deletions.
24 changes: 14 additions & 10 deletions lib/ffi-libarchive/entry.rb
Original file line number Diff line number Diff line change
Expand Up @@ -181,12 +181,14 @@ def copy_lstat(filename)
raise "ffi-inliner build for copy_stat failed:\n#{e}"
end

stat = Archive::Stat.ffi_libarchive_create_lstat(filename)
raise Error, "Copy stat failed: #{Archive::Stat.ffi_error}" if stat.null?
begin
stat = Archive::Stat.ffi_libarchive_create_lstat(filename)
raise Error, "Copy stat failed: #{Archive::Stat.ffi_error}" if stat.null?

C.archive_entry_copy_stat(entry, stat)
ensure
Archive::Stat.ffi_libarchive_free_stat(stat)
C.archive_entry_copy_stat(entry, stat)
ensure
Archive::Stat.ffi_libarchive_free_stat(stat)
end
end

def copy_pathname(file_name)
Expand All @@ -207,12 +209,14 @@ def copy_stat(filename)
raise "ffi-inliner build for copy_stat failed:\n#{e}"
end

stat = Archive::Stat.ffi_libarchive_create_stat(filename)
raise Error, "Copy stat failed: #{Archive::Stat.ffi_error}" if stat.null?
begin
stat = Archive::Stat.ffi_libarchive_create_stat(filename)
raise Error, "Copy stat failed: #{Archive::Stat.ffi_error}" if stat.null?

C.archive_entry_copy_stat(entry, stat)
ensure
Archive::Stat.ffi_libarchive_free_stat(stat)
C.archive_entry_copy_stat(entry, stat)
ensure
Archive::Stat.ffi_libarchive_free_stat(stat)
end
end

def copy_symlink(slnk)
Expand Down

0 comments on commit dae72e2

Please sign in to comment.