Fix NULL pointer dereference crashes
authorwinterrace <hauptadmin@gmail.com>
Tue, 20 Aug 2019 21:34:00 +0000 (23:34 +0200)
committerNathan Hjelm <hjelmn@google.com>
Thu, 22 Aug 2019 04:05:57 +0000 (21:05 -0700)
Signed-off-by: Nathan Hjelm <hjelmn@google.com>
libusb/os/poll_windows.c
libusb/version_nano.h

index 5282e7d..c8eff81 100644 (file)
@@ -71,8 +71,8 @@ static void usbi_dec_fd_table()
 
 static void smart_realloc_fd_table_space(int inc)
 {
-       if (fd_count + inc > fd_size) {
-               struct file_descriptor **p = (struct file_descriptor *)realloc(fd_table, (fd_size + INC_FDS_EACH) * sizeof(struct file_descriptor *));
+       if (fd_table == NULL || fd_count + inc > fd_size) {
+               struct file_descriptor **p = (struct file_descriptor **)realloc(fd_table, (fd_size + INC_FDS_EACH) * sizeof(struct file_descriptor *));
                if (p != NULL) {
                        memset(p + fd_size, 0, INC_FDS_EACH * sizeof(struct file_descriptor *));
                        fd_size += INC_FDS_EACH;
index 9447804..8dc8177 100644 (file)
@@ -1 +1 @@
-#define LIBUSB_NANO 11394
+#define LIBUSB_NANO 11395