From 6df4f0082289934a10ad0c79387558794eb42317 Mon Sep 17 00:00:00 2001 From: Jef Driesen Date: Mon, 10 Nov 2014 22:04:55 +0100 Subject: [PATCH] Fix a NULL pointer dereference. --- src/suunto_eonsteel.c | 4 ++++ src/suunto_eonsteel_parser.c | 2 ++ 2 files changed, 6 insertions(+) diff --git a/src/suunto_eonsteel.c b/src/suunto_eonsteel.c index f17c9fb..1661fa6 100644 --- a/src/suunto_eonsteel.c +++ b/src/suunto_eonsteel.c @@ -383,6 +383,10 @@ static struct directory_entry *parse_dirent(suunto_eonsteel_device_t *eon, int n p += 8 + namelen + 1; len -= 8 + namelen + 1; entry = alloc_dirent(type, namelen, (const char *) name); + if (!entry) { + ERROR(eon->base.context, "out of memory"); + break; + } entry->next = old; old = entry; } diff --git a/src/suunto_eonsteel_parser.c b/src/suunto_eonsteel_parser.c index 1f9605e..dbbcb43 100644 --- a/src/suunto_eonsteel_parser.c +++ b/src/suunto_eonsteel_parser.c @@ -479,6 +479,8 @@ suunto_eonsteel_parser_create(dc_parser_t **out, dc_context_t *context, unsigned return DC_STATUS_INVALIDARGS; eon = (suunto_eonsteel_parser_t *) calloc(1, sizeof(*eon)); + if (!eon) + return DC_STATUS_NOMEMORY; parser_init(&eon->base, context, &suunto_eonsteel_parser_vtable);