From 77ec7522485c0bf1f48669d6eca0d09366c3bbd7 Mon Sep 17 00:00:00 2001 From: Aidan MacDonald Date: Sun, 25 Jul 2021 14:50:31 +0100 Subject: shortcuts: fix file handle leak on OOM condition Change-Id: If09db7a084d83e9bdeeafb8e8f434fcb502c45c5 --- apps/shortcuts.c | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) 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; -- cgit v1.2.3