Subject: | Non-numeric return value in X11::Protocol::num causes error message in X11::Protocol::get_request |
In X11::Protocol, the get_request method checks for numeric values on line 2019:
sub get_request {
my $self = shift;
my($name) = @_;
my($major, $minor);
$major = $self->num('Request', $name);
Show quoted text
>>>>> if (int($major) != 0) { # Core request
return ($self->{'requests'}[$major], $major);
} else { # Extension request
croak "Unknown request `$name'" unless
exists $self->{'ext_request_num'}{$name};
($major, $minor) = @{$self->{'ext_request_num'}{$name}};
croak "Unknown request `$name'" if int($major) == 0;
return ($self->{'ext_request'}{$major}[$minor], $major, $minor);
}
}
However, the num method returns back the NAME of the request ($name) if it is not found in the const_num or ext_const_num hashes. This causes an error such as "Argument "XCMiscGetVersion" isn't numeric in int at /usr/lib/perl5/site_perl/5.8.0/X11/Protocol.pm line 2019" to be printed.
Wouldn't it be preferable to have num return '0' when it doesn't find a number to hash to (thus telling it to skip to the next conditional)? Alternatively, perhaps line 2019 should be changed to:
if (($major =~ /^\d+$/o) && int($major) != 0) { # Core request
So it only tries to 'int' the value if it is in fact a number.