Commit 913d68bb authored by Tomoyuki Sahara's avatar Tomoyuki Sahara

fix an off-by-one error.

parent 57482ef3
...@@ -60,8 +60,9 @@ static char ...@@ -60,8 +60,9 @@ static char
* String which will be the replacement * 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; char *ret;
int i, count = 0; int i, count = 0;
...@@ -75,7 +76,7 @@ static char ...@@ -75,7 +76,7 @@ static char
} }
} }
ret = malloc(i + count * (newlen - oldlen)); ret = malloc(i + count * (newlen - oldlen) + 1);
if (ret == NULL) if (ret == NULL)
exit(EXIT_FAILURE); exit(EXIT_FAILURE);
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment