Skip to content

Commit

Permalink
fix: warnings with new libextism - don't unpack even 0 bytes from NUL…
Browse files Browse the repository at this point in the history
…L pointers
  • Loading branch information
G4Vi committed Oct 9, 2024
1 parent 64f4e61 commit 754e681
Showing 1 changed file with 3 additions and 2 deletions.
5 changes: 3 additions & 2 deletions Extism/lib/Extism/Function.pm
Original file line number Diff line number Diff line change
Expand Up @@ -91,16 +91,16 @@ sub set_namespace {

sub load_raw_array {
my ($ptr, $elm_size, $n) = @_;
$n or return [];
my $input_array = unpack('P'.($elm_size * $n), pack('Q', $ptr));
my @input_packed = unpack("(a$elm_size)*", $input_array);
return \@input_packed;
}

sub host_function_caller_perl {
my ($current_plugin, $input_ptr, $input_len, $output_ptr, $output_len, $user_data) = @_;
#print Dumper(\@_);
local $Extism::CurrentPlugin::instance = $current_plugin;
my $input_packed = \@{load_raw_array($input_ptr, 16, $input_len)};
my $input_packed = load_raw_array($input_ptr, 16, $input_len);
my @input = map {
my $type = unpack('L', $_);
my $value = substr($_, 8);
Expand All @@ -126,6 +126,7 @@ sub host_function_caller_perl {
}
my @outputs = $user_data->{func}(@input);
scalar(@outputs) <= $output_len or croak "host function returned too many outputs";
$output_len or return;
{
my $i = 0;
foreach my $item (@{$user_data->{conversions}{outputs}}) {
Expand Down

0 comments on commit 754e681

Please sign in to comment.