From: Pierre Habouzit Date: Fri, 1 Dec 2006 10:41:59 +0000 (+0100) Subject: workarounds, I do not understand why it segfault, it should *NOT* X-Git-Url: http://git.madism.org/?a=commitdiff_plain;h=75b25db9f40ea7bbd11e63652d5fae591b3f1206;p=apps%2Fmadmutt.git workarounds, I do not understand why it segfault, it should *NOT* Signed-off-by: Pierre Habouzit --- diff --git a/lib-lib/str.c b/lib-lib/str.c index e4616e6..ab603da 100644 --- a/lib-lib/str.c +++ b/lib-lib/str.c @@ -117,16 +117,12 @@ ssize_t m_strncpy(char *dst, ssize_t n, const char *src, ssize_t l) char *m_strrtrim(char *s) { - if (s) { - char *p = s + m_strlen(s); + ssize_t len = m_strlen(s); - while (p > s && ISSPACE(p[-1])) { - *--p = '\0'; - } - return p; - } + while (len > 1 && ISSPACE(s[len - 1])) + s[--len] = '\0'; - return NULL; + return s + len; } const char *m_stristrn(const char *haystack, const char *needle, ssize_t nlen) diff --git a/lib-mime/rfc1524.c b/lib-mime/rfc1524.c index 5b6eb50..fc02062 100644 --- a/lib-mime/rfc1524.c +++ b/lib-mime/rfc1524.c @@ -169,7 +169,8 @@ static char *parse_field(char *p, char **field, char **value) *p++ = '\0'; case '\0': m_strrtrim(*field); - m_strrtrim(*value); + if (*value) + m_strrtrim(*value); return p; case '\\':