Small bug in cusblinux.c

Supporting 2.6 and up
simuloid
Fresh meat
Posts: 1
Joined: Thu Jan 12, 2012 9:25 am
Contact:

Small bug in cusblinux.c

Postby simuloid » Thu Jan 12, 2012 9:43 am

I am running under Fedora 15, Linux version 2.6.40.6-0.fc15.i686.PAE (mockbuild@x86-17.phx2.fedoraproject.org) (gcc version 4.6.1 20110908 (Red Hat 4.6.1-9) (GCC) ) #1 SMP Tue Oct 4 00:44:38 UTC 2011.

I built the phidgets21 library from source, installed libusb and libusb-devel so that I had access to libusb-0.1.

I then compiled and ran the example Encoder-simple.c without any device attached. The program core-dumped with sigsegv. The problem was in cusblinux.c at line 421. To summarize, a call is made udev = usb_open(...). Then udev is checked for null (which it will be if no device is present). If udev is null, then the code calls usb_close(udev). If the argument to usb_close is null, the result is a segmentation fault.

I fixed this on my install by removing the call to usb_close, since if the usb_open failed there should be no reason to call usb_close.

Does this sound sane to you guys?

Thanks!

Return to “Linux”

Who is online

Users browsing this forum: No registered users and 4 guests