aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorbug1 <bug1@69ca8d6d-28ef-0310-b511-8ec308f3f277>2003-09-14 01:25:31 +0000
committerbug1 <bug1@69ca8d6d-28ef-0310-b511-8ec308f3f277>2003-09-14 01:25:31 +0000
commit06ee5e29004bba10b3b7004d43667e9ad4c8d457 (patch)
tree4b4341e85e7f558c11662e04ed171e758ed64af1
parent54eaac0781e1fcb641c21543a1b97c2cbb248edc (diff)
downloadbusybox-w32-06ee5e29004bba10b3b7004d43667e9ad4c8d457.tar.gz
busybox-w32-06ee5e29004bba10b3b7004d43667e9ad4c8d457.tar.bz2
busybox-w32-06ee5e29004bba10b3b7004d43667e9ad4c8d457.zip
Fix some memory allocation problems
git-svn-id: svn://busybox.net/trunk/busybox@7499 69ca8d6d-28ef-0310-b511-8ec308f3f277
-rw-r--r--editors/sed.c9
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)
1057 hold_space_size = strlen(hold_space); 1057 hold_space_size = strlen(hold_space);
1058 } 1058 }
1059 hold_space = xrealloc(hold_space, hold_space_size + strlen(pattern_space) + 2); 1059 hold_space = xrealloc(hold_space, hold_space_size + strlen(pattern_space) + 2);
1060 strcat(hold_space, "\n"); 1060 if (hold_space_size) {
1061 strcat(hold_space, "\n");
1062 } else {
1063 hold_space[0] = '\n';
1064 }
1061 strcat(hold_space, pattern_space); 1065 strcat(hold_space, pattern_space);
1062 break; 1066 break;
1063 } 1067 }
@@ -1103,6 +1107,7 @@ static void process_file(FILE * file)
1103 1107
1104 if (deleted) 1108 if (deleted)
1105 break; 1109 break;
1110
1106 } 1111 }
1107 1112
1108 /* we will print the line unless we were told to be quiet or if the 1113 /* 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)
1155 else { 1160 else {
1156 char *str_cmd = strdup(argv[optind]); 1161 char *str_cmd = strdup(argv[optind]);
1157 1162
1158 add_cmd_str(strdup(str_cmd)); 1163 add_cmd_str(strd_cmd);
1159 free(str_cmd); 1164 free(str_cmd);
1160 optind++; 1165 optind++;
1161 } 1166 }