diff --git a/gtk/usbutil.c b/gtk/usbutil.c
index 3bd7660..0649794 100644
--- a/gtk/usbutil.c
+++ b/gtk/usbutil.c
@@ -19,7 +19,9 @@
License along with this library; if not, see .
*/
-#include "config.h"
+#ifdef HAVE_CONFIG_H
+# include "config.h"
+#endif
#include
#include
@@ -149,7 +151,7 @@ static gboolean spice_usbutil_parse_usbids(gchar *path)
usbids_vendor_count++;
}
- usbids_vendor_info = g_new(usb_vendor_info, usbids_vendor_count);
+ usbids_vendor_info = g_new(usb_vendor_info, usbids_vendor_count + 1);
product_info = g_new(usb_product_info, product_count);
usbids_vendor_count = 0;
@@ -162,6 +164,7 @@ static gboolean spice_usbutil_parse_usbids(gchar *path)
id = strtoul(line, &line, 16);
while (isspace(line[0]))
line++;
+
usbids_vendor_info[usbids_vendor_count].vendor_id = id;
snprintf(usbids_vendor_info[usbids_vendor_count].name,
VENDOR_NAME_LEN, "%s", line);
@@ -309,3 +312,13 @@ void spice_usb_util_get_device_strings(int bus, int address,
}
#endif
+
+#ifdef USBUTIL_TEST
+int main()
+{
+ if (spice_usbutil_load_usbids())
+ exit(0);
+
+ exit(1);
+}
+#endif