diff options
author | Uri Lublin <uril@redhat.com> | 2020-11-11 20:03:57 +0200 |
---|---|---|
committer | Uri Lublin <uril@redhat.com> | 2020-11-23 19:11:36 +0200 |
commit | 032ca202f839fe1c49cddfd2b0459f9fecc23c86 (patch) | |
tree | 58d3f687c9d5c0f587183c3a7d2c5469a3b3c12a | |
parent | 20eebc549da508c82e139120b577b047c76964c3 (diff) |
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 <uril@redhat.com>
-rw-r--r-- | src/usbutil.c | 7 |
1 files changed, 7 insertions, 0 deletions
diff --git a/src/usbutil.c b/src/usbutil.c index 7d7f38a..f29302b 100644 --- a/src/usbutil.c +++ b/src/usbutil.c @@ -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); |