as/tunit.c: check for NULL before applying container_of()

This commit is contained in:
Mikael Pettersson 2015-05-01 14:08:12 +02:00
parent 772d5e4061
commit a5a68a70b7

View File

@ -48,7 +48,7 @@ static uintptr_t string_hash(const char *string)
*/
static struct section *section_from_hashnode(const struct hashnode *hashnode)
{
return container_of(hashnode, struct section, hashnode);
return hashnode ? container_of(hashnode, struct section, hashnode) : NULL;
}
static int section_eq(const struct hashnode *hashnode, const void *data)
@ -195,7 +195,7 @@ void strtab_init(struct strtab *strtab, const char *name)
*/
static struct symbol *symbol_from_hashnode(const struct hashnode *hashnode)
{
return container_of(hashnode, struct symbol, hashnode);
return hashnode ? container_of(hashnode, struct symbol, hashnode) : NULL;
}
static int symbol_eq(const struct hashnode *hashnode, const void *data)