From c93d4ebb79f5930f6b9eeba2f04ca3b237ea8618 Mon Sep 17 00:00:00 2001 From: Elizabeth Mattijsen Date: Mon, 30 Sep 2024 13:58:26 +0200 Subject: [PATCH] Make sure there is a bare Exifdata object always 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 --- lib/Image/Libexif.rakumod | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/lib/Image/Libexif.rakumod b/lib/Image/Libexif.rakumod index f694213..4cc0e44 100644 --- a/lib/Image/Libexif.rakumod +++ b/lib/Image/Libexif.rakumod @@ -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"; } @@ -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; }