Fix a NULL pointer dereference.

This commit is contained in:
Jef Driesen 2014-11-10 22:04:55 +01:00
parent 0b0acf7336
commit 6df4f00822
2 changed files with 6 additions and 0 deletions

View File

@ -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;
}

View File

@ -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);