projects
/
fw
/
stlink
/ blobdiff
commit
grep
author
committer
pickaxe
?
search:
re
summary
|
shortlog
|
log
|
commit
|
commitdiff
|
tree
raw
|
inline
| side by side
avoid reading from NULL
[fw/stlink]
/
src
/
stlink-usb.c
diff --git
a/src/stlink-usb.c
b/src/stlink-usb.c
index 8e52c6801488459001a69e434a7e1c88831ef486..b0ee00bed4da904fa4111d9947b998ad21c0e88a 100644
(file)
--- 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));
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));
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_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;
if (sl != NULL) free(sl);
if (slu != NULL) free(slu);
return NULL;