From 913d68bbcd547918a5fa18a056290478dbeb8699 Mon Sep 17 00:00:00 2001 From: Tomoyuki Sahara Date: Tue, 11 Dec 2012 12:38:08 +0900 Subject: fix an off-by-one error. --- mrbgems/generator.c | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/mrbgems/generator.c b/mrbgems/generator.c index 108405b24..76b3ebe1e 100644 --- a/mrbgems/generator.c +++ b/mrbgems/generator.c @@ -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); -- cgit v1.2.3