X-Git-Url: https://git.gag.com/?a=blobdiff_plain;ds=sidebyside;f=src%2Fstlink-usb.c;h=b0ee00bed4da904fa4111d9947b998ad21c0e88a;hb=b05f7008e49fca23765e1b54c2741af15ad65446;hp=8e52c6801488459001a69e434a7e1c88831ef486;hpb=8a190733a2fb6e70b7956c64f04ab258967d0798;p=fw%2Fstlink diff --git a/src/stlink-usb.c b/src/stlink-usb.c index 8e52c68..b0ee00b 100644 --- a/src/stlink-usb.c +++ b/src/stlink-usb.c @@ -720,8 +720,8 @@ stlink_t* stlink_open_usb(const int verbose, int reset, char *p_usb_iserial) { sl = malloc(sizeof (stlink_t)); slu = malloc(sizeof (struct stlink_libusb)); - if (sl == NULL) goto on_error; - if (slu == NULL) goto on_error; + if (sl == NULL) goto on_malloc_error; + if (slu == NULL) goto on_malloc_error; memset(sl, 0, sizeof (stlink_t)); memset(slu, 0, sizeof (struct stlink_libusb)); @@ -867,6 +867,7 @@ on_libusb_error: on_error: if( slu->libusb_ctx) libusb_exit(slu->libusb_ctx); +on_malloc_error: if (sl != NULL) free(sl); if (slu != NULL) free(slu); return NULL;