From b07d69b15852a06183f7b2298436e18150c36958 Mon Sep 17 00:00:00 2001 From: Pierre Habouzit Date: Mon, 30 Oct 2006 17:48:38 +0100 Subject: [PATCH] make m_dupstr return NULL if the string was empty. --- lib-lib/str.h | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/lib-lib/str.h b/lib-lib/str.h index 4ef9d48..8850830 100644 --- a/lib-lib/str.h +++ b/lib-lib/str.h @@ -37,7 +37,8 @@ static inline ssize_t m_strnlen(const char *s, ssize_t n) { } static inline char *m_strdup(const char *s) { - return p_dupstr(s, m_strlen(s)); + ssize_t len = m_strlen(s); + return len ? p_dup(s, len + 1) : NULL; } static inline int m_strcmp(const char *a, const char *b) { -- 2.20.1