make m_dupstr return NULL if the string was empty.
authorPierre Habouzit <madcoder@debian.org>
Mon, 30 Oct 2006 16:48:38 +0000 (17:48 +0100)
committerPierre Habouzit <madcoder@debian.org>
Mon, 30 Oct 2006 16:48:38 +0000 (17:48 +0100)
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) {