Skip to content

usbredirect: fix leak on bad input

Victor Toso requested to merge victortoso/usbredir:covscan into main

Found by covscan:

Error: RESOURCE_LEAK (CWE-772): [#def1] [important]
usbredir-0.12.0/tools/usbredirect.c:55: alloc_fn: Storage is returned from allocation function "g_strsplit".
usbredir-0.12.0/tools/usbredirect.c:55: var_assign: Assigning: "usbid" = storage returned from "g_strsplit(device, "-", 2)".
usbredir-0.12.0/tools/usbredirect.c:76: leaked_storage: Variable "usbid" going out of scope leaks the storage it points to.
#   74|           if (i == n) {
#   75|               libusb_free_device_list(list, true);
#   76|->             return false;
#   77|           }
#   78|

and

Error: RESOURCE_LEAK (CWE-772): [#def2] [important]
usbredir-0.12.0/tools/usbredirect.c:55: alloc_fn: Storage is returned from allocation function "g_strsplit".
usbredir-0.12.0/tools/usbredirect.c:55: var_assign: Assigning: "usbid" = storage returned from "g_strsplit(device, "-", 2)".
usbredir-0.12.0/tools/usbredirect.c:85: leaked_storage: Variable "usbid" going out of scope leaks the storage it points to.
#   83|
#   84|           libusb_free_device_list(list, true);
#   85|->         return true;
#   86|       }
#   87|

Signed-off-by: Victor Toso victortoso@redhat.com

Merge request reports

Loading