make m_dupstr return NULL if the string was empty.
[apps/madmutt.git] / lib-lib / str.h
index 4ef9d48..8850830 100644 (file)
@@ -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) {