If the GD::File returned by e.g. $image.open wasn't actually successfully opened (but is returned regardless,) then calling close on it will result in a segfault.
This manifests when e.g. the examples/polygon.p6 is run from the root directory (so the images sub-directory doesn't exist.)
I think two things need to happen:
GD::File.new or the open call should throw an exception if the file can't be opened
.close should be able to guard against being called on an unopened file handle.
It may be possible to get around both of these by using IO::Handle everywhere and .native-descriptor (possibly with with fdopen ) to pass to the native functions.
If the
GD::File
returned by e.g.$image.open
wasn't actually successfully opened (but is returned regardless,) then callingclose
on it will result in a segfault.This manifests when e.g. the
examples/polygon.p6
is run from the root directory (so theimages
sub-directory doesn't exist.)I think two things need to happen:
GD::File.new or the open call should throw an exception if the file can't be opened
.close
should be able to guard against being called on an unopened file handle.It may be possible to get around both of these by using
IO::Handle
everywhere and.native-descriptor
(possibly with withfdopen
) to pass to the native functions.