diff --git a/include/linux/slab.h b/include/linux/slab.h index 6628d5e4..ef861538 100644 --- a/include/linux/slab.h +++ b/include/linux/slab.h @@ -47,10 +47,12 @@ static inline void *krealloc(void *old, size_t size, gfp_t flags) if (flags & __GFP_ZERO) memset(new, 0, size); - memcpy(new, old, - min(malloc_usable_size(old), - malloc_usable_size(new))); - free(old); + if (old) { + memcpy(new, old, + min(malloc_usable_size(old), + malloc_usable_size(new))); + free(old); + } return new; } diff --git a/tools-util.h b/tools-util.h index 01898e21..568707bc 100644 --- a/tools-util.h +++ b/tools-util.h @@ -20,7 +20,9 @@ #include #include "ccan/darray/darray.h" -void die(const char *, ...); +#define noreturn __attribute__((noreturn)) + +void die(const char *, ...) noreturn; char *mprintf(const char *, ...) __attribute__ ((format (printf, 1, 2))); void *xcalloc(size_t, size_t);