Commit a960087c0ab122b2e0a7effdfab12ee59846d33f

nelisky 2012-03-21T20:41:03

Ztex device removal segfault fixed

1
2
3
4
5
6
7
8
9
10
11
12
13
diff --git a/libztex.c b/libztex.c
index acc5025..ee56bdd 100644
--- a/libztex.c
+++ b/libztex.c
@@ -420,7 +420,7 @@ int libztex_scanDevices (struct libztex_dev_list*** devs_p) {
 
 int libztex_sendHashData (struct libztex_device *ztex, unsigned char *sendbuf) {
   int cnt;
-  if (ztex->hndl == NULL) {
+  if (ztex == NULL || ztex->hndl == NULL) {
     return 0;
   }
   cnt = libusb_control_transfer(ztex->hndl, 0x40, 0x80, 0, 0, sendbuf, 44, 1000);