rlen = strlen(replace);
len = strlen(src);
- result = malloc(len);
+ result = malloc(len + 1);
if (!result) {
ErrPrint("Heap:%s\n", strerror(errno));
return NULL;
char *tmp;
len += (rlen > len ? rlen : len);
- tmp = realloc(result, len);
+ tmp = realloc(result, len + 1);
if (!tmp) {
ErrPrint("Heap: %s\n", strerror(errno));
free(result);
if (r_idx == len) {
char *tmp;
len += (rlen > len ? rlen : len);
- tmp = realloc(result, len);
+ tmp = realloc(result, len + 1);
if (!tmp) {
ErrPrint("Heap: %s\n", strerror(errno));
free(result);
if (r_idx == len) {
char *tmp;
len += (rlen > len ? rlen : len);
- tmp = realloc(result, len);
+ tmp = realloc(result, len + 1);
if (!tmp) {
ErrPrint("Heap: %s\n", strerror(errno));
free(result);
if (idx + rlen >= len) {
char *tmp;
len += (rlen > len ? rlen : len);
- tmp = realloc(result, len);
+ tmp = realloc(result, len + 1);
if (!tmp) {
ErrPrint("Heap: %s\n", strerror(errno));
free(result);