From c75d33752af940e9b0868e31cce064faebef5fe5 Mon Sep 17 00:00:00 2001 From: Qball Cow Date: Mon, 31 Dec 2007 18:41:08 +0000 Subject: Don't let xstrdup(s) crash crash when s is NULL, but return Null in stead git-svn-id: https://svn.musicpd.org/mpd/trunk@7111 09075e82-0dd4-0310-85a5-a0d7c8717e4f --- src/utils.c | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/src/utils.c b/src/utils.c index e9865aa24..bfe3de200 100644 --- a/src/utils.c +++ b/src/utils.c @@ -121,7 +121,11 @@ unsigned long readLEuint32(const unsigned char *p) mpd_malloc char *xstrdup(const char *s) { - char *ret = strdup(s); + char *ret; + /* Return NULL, if s is NULL */ + if(!s) + return NULL; + ret = strdup(s); if (mpd_unlikely(!ret)) FATAL("OOM: strdup\n"); return ret; -- cgit v1.2.3