summaryrefslogtreecommitdiff
path: root/apps/shortcuts.c
diff options
context:
space:
mode:
authorAidan MacDonald <amachronic@protonmail.com>2021-07-25 14:50:31 +0100
committerAidan MacDonald <amachronic@protonmail.com>2021-07-25 14:53:00 +0100
commit77ec7522485c0bf1f48669d6eca0d09366c3bbd7 (patch)
treec76424544f6535bad0e7f9faab856d84d6af7b6f /apps/shortcuts.c
parentd0536b8b6b5263eb54a9b4f1ef6998a8e90dbbd1 (diff)
shortcuts: fix file handle leak on OOM condition
Change-Id: If09db7a084d83e9bdeeafb8e8f434fcb502c45c5
Diffstat (limited to 'apps/shortcuts.c')
-rw-r--r--apps/shortcuts.c5
1 files changed, 4 insertions, 1 deletions
diff --git a/apps/shortcuts.c b/apps/shortcuts.c
index 9955b7f19d..7b224dde2f 100644
--- a/apps/shortcuts.c
+++ b/apps/shortcuts.c
@@ -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;