diff options
| author | Tomoyuki Sahara <[email protected]> | 2012-12-11 12:38:08 +0900 |
|---|---|---|
| committer | Tomoyuki Sahara <[email protected]> | 2012-12-11 12:58:05 +0900 |
| commit | 913d68bbcd547918a5fa18a056290478dbeb8699 (patch) | |
| tree | 729779f6148f0c10f607be69852ff6a9c8ea823a | |
| parent | 57482ef3f04f158b9ec2f73369e1b697de8124c3 (diff) | |
| download | mruby-913d68bbcd547918a5fa18a056290478dbeb8699.tar.gz mruby-913d68bbcd547918a5fa18a056290478dbeb8699.zip | |
fix an off-by-one error.
| -rw-r--r-- | mrbgems/generator.c | 7 |
1 files 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); |
