uinput: check for asprintf failure

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>
This commit is contained in:
Peter Hutterer 2014-03-18 13:55:21 +10:00
parent 2ad8980c5a
commit f29008b758

View file

@ -179,7 +179,8 @@ fetch_device_node(const char *path)
/* 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]);
}