Skip Menu |

This queue is for tickets about the Device-USB CPAN distribution.

Report information
The Basics
Id: 55611
Status: resolved
Estimated: 5 min
Worked: 5 min
Priority: 0/
Queue: Device-USB

People
Owner: Nobody in particular
Requestors: Stephen.Cliffe [...] andrew.com
Cc:
AdminCc:

Bug Information
Severity: (no value)
Broken in: (no value)
Fixed in: 0.32



Subject: Pointer being passed as (nil) in get_descriptor
Date: Tue, 16 Mar 2010 06:36:17 +0800
To: "bug-device-usb [...] rt.cpan.org" <bug-device-usb [...] rt.cpan.org>
From: "Cliffe, Stephen" <Stephen.Cliffe [...] andrew.com>
I'm having a problem with Device::USB, specifically I'm getting the following warning: Argument "\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0..." isn't numeric in subroutine entry at /usr/lib/perl5/site_perl/5.8.8/i386-linux-thread-multi/Device/USB/Device.pm line 585, <DATA> line 1. This is then followed by a Segmentation fault. This code from Device::USB that is causing this is: sub get_descriptor { my $self = shift; my $type = shift; my $index = shift; $self->_assert_open(); my $buf = "\0" x MAX_BUFFER_SIZE; my $retlen = Device::USB::libusb_get_descriptor( $self->{handle}, $type, $index, $buf, MAX_BUFFER_SIZE ); return if $retlen < 0; return substr( $buf, 0, $retlen ); } The argument $buf ends up as (nil) in Device::USB::libusb_get_descriptor so there appears to be some problem with the argument passing. I posted on Perl Monks (http://www.perlmonks.org/?node_id=828623) about this and the response was that it's a typemap problem (the buffer should be declared as a char * instead of void *) in libusb_get_descriptor. This fixed the problem for me. Note that there are a number of other occurrences of this in other functions. Steve.