From 4dc1d25a30825091b0a285eb3b36121a066b30ee Mon Sep 17 00:00:00 2001 From: Glenn L McGrath Date: Sun, 14 Sep 2003 01:25:31 +0000 Subject: [PATCH] Fix some memory allocation problems --- editors/sed.c | 9 +++++++-- 1 file 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++; } -- 2.25.1