This doesn't really do much here, but strictly speaking: if asprintf returns
-1, devnode is undefined. So reset it to NULL to avoid weird pointers. And
also free the rest of the names if we ever have more than one device - which
also shouldn't happen.
Signed-off-by: Peter Hutterer <peter.hutterer@who-t.net>
Reviewed-by: Benjamin Tissoires <benjamin.tissoires@gmail.com>
/* ndev should only ever be 1 */
for (i = 0; i < ndev; i++) {
- asprintf(&devnode, "/dev/input/%s", namelist[i]->d_name);
+ if (!devnode && asprintf(&devnode, "/dev/input/%s", namelist[i]->d_name) == -1)
+ devnode = NULL;
free(namelist[i]);
}