diff --git a/ChangeLog b/ChangeLog index 6a2c4ec..dd0a244 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,6 +1,7 @@ 2010-03-04 Caolán McNamara : * hun#1724558 tidy substring.c a little * hun#1999737 add some malloc checks + * hun#2005643 tidy string functions 2010-02-23 László Németh : * hyphen.c: fix lefthyphenmin calculation for UTF-8 encoded input diff --git a/csutil.c b/csutil.c index 515e9ae..af21f2c 100644 --- a/csutil.c +++ b/csutil.c @@ -42,9 +42,9 @@ char * mystrdup(const char * s) { char * d = NULL; if (s) { - int sl = strlen(s); - d = (char *) malloc(((sl+1) * sizeof(char))); - if (d) memcpy(d,s,((sl+1)*sizeof(char))); + int sl = strlen(s+1); + d = (char *) malloc(sl); + if (d) memcpy(d,s,sl); } return d; }