Definitely a buffer overflow. If I step over either of the lines indicated in this function, the segfault happens. Sometimes it might not happen until you step on the following line. One time when I did this, the editor window contents got partially corrupted, but slick kept on running for a few more steps before it finally segfaulted.
use Test::More;
sub is_golden {
my ($actual_file, $golden_file, $msg) = @_;
local $/ = undef;
my $golden;
if ( -e $golden_file ) {
open( GOLD, "<$golden_file" ) or die "Could not open $golden_file: $!\n";
$golden = <GOLD>; # <---- happens when you step over this line
close( GOLD );
}
if ( ! open( GOT, "<$actual_file" ) ) {
fail( "Can't open $actual_file: $!\n" );
next;
}
my $got = <GOT>; # <---- or happens when you step over this line
if ( ! ( is( $got, $golden, $msg) or diag( "See: $golden_file.actual" ) ) ) {
open( ACT, ">$golden_file.actual" ) or die $!;
print ACT $got;
close( ACT );
}
}