From d944fafe8cee766e5c3c601a16797b890420802c Mon Sep 17 00:00:00 2001 From: Gabriel Kihlman Date: Wed, 18 Dec 2019 12:34:30 +0100 Subject: [PATCH 16/25] Handle the case when new_device() returns NULL (malloc failure) Signed-off-by: Gustavo B. Schenkel --- u2f-host/devs.c | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/u2f-host/devs.c b/u2f-host/devs.c index aa76c9f..7650743 100644 --- a/u2f-host/devs.c +++ b/u2f-host/devs.c @@ -435,6 +435,11 @@ u2fh_devs_discover (u2fh_devs * devs, unsigned *max_index) if (usage_page == FIDO_USAGE_PAGE && usage == FIDO_USAGE_U2FHID) { dev = new_device (devs); + if (dev == NULL) + { + res = U2FH_MEMORY_ERROR; + goto out; + } dev->devh = hid_open_path (cur_dev->path); if (dev->devh != NULL) { -- 2.32.0