diff options
author | Glenn L McGrath <bug1@ihug.co.nz> | 2003-09-14 01:25:31 +0000 |
---|---|---|
committer | Glenn L McGrath <bug1@ihug.co.nz> | 2003-09-14 01:25:31 +0000 |
commit | 4dc1d25a30825091b0a285eb3b36121a066b30ee (patch) | |
tree | 4b4341e85e7f558c11662e04ed171e758ed64af1 /editors/sed.c | |
parent | f36635cec6da728fe06b849089ce2f6c1690dc67 (diff) |
Fix some memory allocation problems
Diffstat (limited to 'editors/sed.c')
-rw-r--r-- | editors/sed.c | 9 |
1 files changed, 7 insertions, 2 deletions
diff --git a/editors/sed.c b/editors/sed.c index 75ed53eb7..6dbb1fb8f 100644 --- a/editors/sed.c +++ b/editors/sed.c @@ -1057,7 +1057,11 @@ static void process_file(FILE * file) hold_space_size = strlen(hold_space); } hold_space = xrealloc(hold_space, hold_space_size + strlen(pattern_space) + 2); - strcat(hold_space, "\n"); + if (hold_space_size) { + strcat(hold_space, "\n"); + } else { + hold_space[0] = '\n'; + } strcat(hold_space, pattern_space); break; } @@ -1103,6 +1107,7 @@ static void process_file(FILE * file) if (deleted) break; + } /* we will print the line unless we were told to be quiet or if the @@ -1155,7 +1160,7 @@ extern int sed_main(int argc, char **argv) else { char *str_cmd = strdup(argv[optind]); - add_cmd_str(strdup(str_cmd)); + add_cmd_str(strd_cmd); free(str_cmd); optind++; } |