From a5a68a70b782a6c2bd1f386ab3deccfdab3038fe Mon Sep 17 00:00:00 2001 From: Mikael Pettersson Date: Fri, 1 May 2015 14:08:12 +0200 Subject: [PATCH] as/tunit.c: check for NULL before applying container_of() --- as/tunit.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/as/tunit.c b/as/tunit.c index 9e24f0a..9aa2541 100644 --- a/as/tunit.c +++ b/as/tunit.c @@ -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)