diff options
author | Marcus Meissner <marcus@jet.franken.de> | 2012-07-19 16:52:00 +0000 |
---|---|---|
committer | Marcus Meissner <marcus@jet.franken.de> | 2012-07-19 16:52:00 +0000 |
commit | f598b0e636e53d28b53581400e111fb323f2618b (patch) | |
tree | bc4511baf5caedbfbd3264a9c0b80ba9fe79e768 | |
parent | dded3b1b52b1df3bf9456ba6399d2d8283ad1cbe (diff) | |
download | libgphoto2-f598b0e636e53d28b53581400e111fb323f2618b.tar.gz |
do not use the global context to avoid crashes
git-svn-id: https://svn.code.sf.net/p/gphoto/code/branches/libgphoto2-2_4/libgphoto2@14065 67ed7778-7388-44ab-90cf-0a291f65f57c
-rw-r--r-- | libgphoto2_port/libusb1/libusb1.c | 9 |
1 files changed, 6 insertions, 3 deletions
diff --git a/libgphoto2_port/libusb1/libusb1.c b/libgphoto2_port/libusb1/libusb1.c index c6b16aa91..c6a03dc5f 100644 --- a/libgphoto2_port/libusb1/libusb1.c +++ b/libgphoto2_port/libusb1/libusb1.c @@ -119,6 +119,7 @@ gp_port_library_list (GPPortInfoList *list) GPPortInfo info; int nrofdevices = 0; int d, i, i1, i2, unknownint; + libusb_context *ctx; /* generic matcher. This will catch passed XXX,YYY entries for instance. */ info.type = GP_PORT_USB; @@ -126,8 +127,8 @@ gp_port_library_list (GPPortInfoList *list) strcpy (info.path, "^usb:"); CHECK (gp_port_info_list_append (list, info)); - libusb_init (NULL); - gp_nrofdevs = load_devicelist (NULL); + libusb_init (&ctx); + gp_nrofdevs = load_devicelist (ctx); for (d = 0; d < gp_nrofdevs; d++) { /* Devices which are definitely not cameras. */ @@ -239,7 +240,9 @@ gp_port_library_list (GPPortInfoList *list) strcpy (info.path, "usb:"); CHECK (gp_port_info_list_append (list, info)); } - libusb_exit (NULL); + libusb_exit (ctx); + gp_nrofdevs = 0; + gp_devs = NULL; return (GP_OK); } |