fix an off-by-one error.

This commit is contained in:
Tomoyuki Sahara
2012-12-11 12:38:08 +09:00
parent 57482ef3f0
commit 913d68bbcd
+4 -3
View File
@@ -60,8 +60,9 @@ static char
* String which will be the replacement
*
*/
static char
*replace(const char *s, const char *old, const char *new)
static char *
replace(const char *s, const char *old, const char *new)
{
char *ret;
int i, count = 0;
@@ -75,7 +76,7 @@ static char
}
}
ret = malloc(i + count * (newlen - oldlen));
ret = malloc(i + count * (newlen - oldlen) + 1);
if (ret == NULL)
exit(EXIT_FAILURE);