DX 50: Fix file descriptor leak on error
Unimportant change, still good style. cppcheck reported: [rockbox/firmware/target/hosted/android/dx50/button-dx50.c:92]: (error) Resource leak: fd [rockbox/firmware/target/hosted/android/dx50/button-dx50.c:98]: (error) Resource leak: fd Change-Id: Ic1831382219c44e7bef71cb2391646c9910d2369
This commit is contained in:
parent
575ec8902e
commit
1eb1bc24f2
1 changed files with 2 additions and 0 deletions
|
@ -89,12 +89,14 @@ static int open_device(const char *device, int print_flags)
|
|||
new_ufds = realloc(ufds, sizeof(ufds[0]) * (nfds + 1));
|
||||
if(new_ufds == NULL) {
|
||||
fprintf(stderr, "out of memory\n");
|
||||
close(fd);
|
||||
return -1;
|
||||
}
|
||||
ufds = new_ufds;
|
||||
new_device_names = realloc(device_names, sizeof(device_names[0]) * (nfds + 1));
|
||||
if(new_device_names == NULL) {
|
||||
fprintf(stderr, "out of memory\n");
|
||||
close(fd);
|
||||
return -1;
|
||||
}
|
||||
device_names = new_device_names;
|
||||
|
|
Loading…
Reference in a new issue