Commit 032ca202 authored by Uri Lublin's avatar Uri Lublin
Browse files

spice_usbutil_parse_usbids: verify at least one vendor and product



Fixes the following clang warning:
  src/usbutil.c:148:52: warning: Use of zero-allocated memory
  ...

   product_info[product_count].product_id = id;
                                          ^
   146|               while (isspace(line[0]))
   147|                   line++;
   148|->             product_info[product_count].product_id = id;
   149|               snprintf(product_info[product_count].name,
   150|                        PRODUCT_NAME_LEN, "%s", line);
Signed-off-by: Uri Lublin's avatarUri Lublin <uril@redhat.com>
parent 20eebc54
......@@ -113,6 +113,13 @@ static gboolean spice_usbutil_parse_usbids(gchar *path)
usbids_vendor_count++;
}
if (usbids_vendor_info == 0 || product_count == 0) {
usbids_vendor_count = -1;
g_strfreev(lines);
g_free(contents);
return FALSE;
}
usbids_vendor_info = g_new(usb_vendor_info, usbids_vendor_count);
product_info = g_new(usb_product_info, product_count);
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment