diff --git a/firmware/target/hosted/android/dx50/button-dx50.c b/firmware/target/hosted/android/dx50/button-dx50.c index 5ab58ce420..250b448491 100644 --- a/firmware/target/hosted/android/dx50/button-dx50.c +++ b/firmware/target/hosted/android/dx50/button-dx50.c @@ -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;