strdup returns NULL in case memory allocation failure occurs.
If Null check is not there, it will crash while dereferencing in "strrchr".
Closes #66
Signed-off-by: Chris Dickens <christopher.a.dickens@gmail.com>
}
parent_sysfs_dir = strdup(sysfs_dir);
+ if (NULL == parent_sysfs_dir) {
+ return LIBUSB_ERROR_NO_MEM;
+ }
if (NULL != (tmp = strrchr(parent_sysfs_dir, '.')) ||
NULL != (tmp = strrchr(parent_sysfs_dir, '-'))) {
dev->port_number = atoi(tmp + 1);
-#define LIBUSB_NANO 10984
+#define LIBUSB_NANO 10985