Chevck first for NULL before writing anything to the alloceted structure
authorUwe Bonnes <bon@elektron.ikp.physik.tu-darmstadt.de>
Sat, 10 Dec 2011 16:17:25 +0000 (17:17 +0100)
committerUwe Bonnes <bon@elektron.ikp.physik.tu-darmstadt.de>
Sat, 10 Dec 2011 16:17:25 +0000 (17:17 +0100)
flash/main.c

index 39910b63665ad388c658951ad43bf6db7639571b..9033b17b6069828817cad513a70516108b17a804 100644 (file)
@@ -91,14 +91,14 @@ int main(int ac, char** av)
   if (o.devname != NULL) /* stlinkv1 */
   {
     sl = stlink_v1_open(50);
   if (o.devname != NULL) /* stlinkv1 */
   {
     sl = stlink_v1_open(50);
-    sl->verbose = 50;
     if (sl == NULL) goto on_error;
     if (sl == NULL) goto on_error;
+    sl->verbose = 50;
   }
   else /* stlinkv2 */
   {
     sl = stlink_open_usb(50);
   }
   else /* stlinkv2 */
   {
     sl = stlink_open_usb(50);
-    sl->verbose = 50;
     if (sl == NULL) goto on_error;
     if (sl == NULL) goto on_error;
+    sl->verbose = 50;
   }
 
   if (stlink_current_mode(sl) == STLINK_DEV_DFU_MODE)
   }
 
   if (stlink_current_mode(sl) == STLINK_DEV_DFU_MODE)