summaryrefslogtreecommitdiff
blob: 25dbd0d107db92aed6cc90b72f4d5108e8ae811c (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
diff -ur avarice-2.10.orig/src/jtag2usb.cc avarice-2.10/src/jtag2usb.cc
--- avarice-2.10.orig/src/jtag2usb.cc	2007-02-18 00:41:46.000000000 +0200
+++ avarice-2.10/src/jtag2usb.cc	2009-08-07 11:53:46.000000000 +0300
@@ -18,7 +18,7 @@
  * This file implements the libusb-based USB connection to a JTAG ICE
  * mkII.
  *
- * $Id: avarice-2.10-gcc44.patch,v 1.1 2009/08/07 08:53:45 ssuominen Exp $
+ * $Id: avarice-2.10-gcc44.patch,v 1.1 2009/08/07 08:53:45 ssuominen Exp $
  */
 
 
@@ -70,7 +70,7 @@
   struct usb_bus *bus;
   struct usb_device *dev;
   usb_dev_handle *udev;
-  char *serno, *cp2;
+  char *devnamecopy, *serno, *cp2;
   u_int16_t pid;
   size_t x;
 
@@ -85,6 +85,9 @@
       break;
     }
 
+  devnamecopy = new char[x = strlen(jtagDeviceName) + 1];
+  memcpy(devnamecopy, jtagDeviceName, x);
+
   /*
    * The syntax for usb devices is defined as:
    *
@@ -95,7 +98,7 @@
    * right-to-left, so only the least significant nibbles need to be
    * specified.
    */
-  if ((serno = strchr(jtagDeviceName, ':')) != NULL)
+  if ((serno = strchr(devnamecopy, ':')) != NULL)
     {
       /* first, drop all colons there if any */
       cp2 = ++serno;
@@ -159,6 +162,8 @@
 	    }
 	}
     }
+
+  delete devnamecopy;
   if (!found)
   {
     printf("did not find any%s USB device \"%s\"\n",