shared.c: do not modify const memory

Noticed-by: zhongjj <zhongjj@lemote.com>
Signed-off-by: Lars Hjemli <hjemli@gmail.com>
This commit is contained in:
Lars Hjemli 2011-05-22 12:45:32 +02:00
parent 084ca50972
commit dc1a8eadd4

View File

@ -100,23 +100,15 @@ void *cgit_free_commitinfo(struct commitinfo *info)
char *trim_end(const char *str, char c)
{
int len;
char *s, *t;
if (str == NULL)
return NULL;
t = (char *)str;
len = strlen(t);
while(len > 0 && t[len - 1] == c)
len = strlen(str);
while(len > 0 && str[len - 1] == c)
len--;
if (len == 0)
return NULL;
c = t[len];
t[len] = '\0';
s = xstrdup(t);
t[len] = c;
return s;
return xstrndup(str, len);
}
char *strlpart(char *txt, int maxlen)