libusb: fix a memory leak in sunos_new_string_list func
authorZhiqiang Liu <lzhq28@mail.ust.edu.cn>
Mon, 27 Jul 2020 09:46:01 +0000 (17:46 +0800)
committerChris Dickens <christopher.a.dickens@gmail.com>
Mon, 10 Aug 2020 17:53:08 +0000 (10:53 -0700)
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 <lzhq28@mail.ustc.edu.cn>
Signed-off-by: Chris Dickens <christopher.a.dickens@gmail.com>
libusb/os/sunos_usb.c
libusb/version_nano.h

index 3e2fb4f..73b96da 100644 (file)
@@ -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;
 
index ea0c971..baac006 100644 (file)
@@ -1 +1 @@
-#define LIBUSB_NANO 11525
+#define LIBUSB_NANO 11526