Skip to content

Commit

Permalink
Make sure there is a bare Exifdata object always
Browse files Browse the repository at this point in the history
It appears that some files don't actually contain any exif data.
Creating an object with such a file would put a type object into
the $!exif attribute, causing later havoc.

This commit ensures that that is at least a bare ExifData object
created when loading a file that doesn't contain any exif data.

An example of such a file is:

   nqp/MoarVM/3rdparty/libuv/docs/src/static/architecture.png

in any Rakudo installation.

Fixes issue #1
  • Loading branch information
lizmat committed Sep 30, 2024
1 parent 6c02fd7 commit c93d4eb
Showing 1 changed file with 2 additions and 2 deletions.
4 changes: 2 additions & 2 deletions lib/Image/Libexif.rakumod
Original file line number Diff line number Diff line change
Expand Up @@ -140,7 +140,7 @@ submethod BUILD(Str :$file?, Buf :$data?)
{
with $file {
if $file.IO.f {
$!exif = exif_data_new_from_file $file;
$!exif = exif_data_new_from_file($file) // exif_data_new;
} else {
fail X::Libexif.new: errno => 1, error => "File $file not found";
}
Expand All @@ -154,7 +154,7 @@ submethod BUILD(Str :$file?, Buf :$data?)
method open(Str $file!)
{
fail X::Libexif.new: errno => 1, error => "File $file not found" if ! $file.IO.e;
$!exif = exif_data_new_from_file $file;
$!exif = exif_data_new_from_file($file) // exif_data_new;
self;
}

Expand Down

0 comments on commit c93d4eb

Please sign in to comment.