From f85dfa654f26d02a3ef3d955ed41bd98b710bd23 Mon Sep 17 00:00:00 2001 From: Zhiqiang Liu Date: Mon, 27 Jul 2020 17:46:01 +0800 Subject: [PATCH] libusb: fix a memory leak in sunos_new_string_list func In sunos_new_string_list func, if alloc list->string fails, we will return NULL without free list, which has alread been allocated successfully. Fixes: 17348731b4 ('Solaris backend depends on Solaris private symbols') Closes #756 Signed-off-by: Zhiqiang Liu Signed-off-by: Chris Dickens --- libusb/os/sunos_usb.c | 4 +++- libusb/version_nano.h | 2 +- 2 files changed, 4 insertions(+), 2 deletions(-) diff --git a/libusb/os/sunos_usb.c b/libusb/os/sunos_usb.c index 3e2fb4f..73b96da 100644 --- a/libusb/os/sunos_usb.c +++ b/libusb/os/sunos_usb.c @@ -248,8 +248,10 @@ sunos_new_string_list(void) if (list == NULL) return (NULL); list->string = calloc(DEFAULT_LISTSIZE, sizeof(char *)); - if (list->string == NULL) + if (list->string == NULL) { + free(list); return (NULL); + } list->nargs = 0; list->listsize = DEFAULT_LISTSIZE; diff --git a/libusb/version_nano.h b/libusb/version_nano.h index ea0c971..baac006 100644 --- a/libusb/version_nano.h +++ b/libusb/version_nano.h @@ -1 +1 @@ -#define LIBUSB_NANO 11525 +#define LIBUSB_NANO 11526 -- 2.7.4