This fixes a segfault in mount (and possibly elsewhere) when invoked
without a -t parameter.
Broken in
7ef9fd7 when the common xalloc.h libs were introduced.
Signed-off-by: Dave Reisner <dreisner@archlinux.org>
static inline char *xstrdup(const char *str)
{
- char *ret = strdup(str);
+ char *ret;
- if (!ret && str)
+ if (!str)
+ return NULL;
+
+ ret = strdup(str);
+
+ if (!ret)
err(XALLOC_EXIT_CODE, "cannot duplicate string");
return ret;
}