diff options
Diffstat (limited to 'include/xalloc.h')
-rw-r--r-- | include/xalloc.h | 6 |
1 files changed, 4 insertions, 2 deletions
diff --git a/include/xalloc.h b/include/xalloc.h index 7b685e718..1f29621ef 100644 --- a/include/xalloc.h +++ b/include/xalloc.h @@ -83,9 +83,11 @@ static inline char *xgethostname(void) size_t sz = get_hostname_max() + 1; name = xmalloc(sizeof(char) * sz); - if (gethostname(name, sz) != 0) - return NULL; + if (gethostname(name, sz) != 0) { + free(name); + return NULL; + } name[sz - 1] = '\0'; return name; } |