shortcuts: fix file handle leak on OOM condition

Change-Id: If09db7a084d83e9bdeeafb8e8f434fcb502c45c5
This commit is contained in:
Aidan MacDonald 2021-07-25 14:50:31 +01:00
parent d0536b8b6b
commit 77ec752248
1 changed files with 4 additions and 1 deletions

View File

@ -372,8 +372,11 @@ void shortcuts_init(void)
if (fd < 0)
return;
first_handle = core_alloc_ex("shortcuts_head", sizeof(struct shortcut_handle), &shortcut_ops);
if (first_handle <= 0)
if (first_handle <= 0) {
close(fd);
return;
}
h = core_get_data(first_handle);
h->next_handle = 0;