aboutsummaryrefslogtreecommitdiff
path: root/editors
diff options
context:
space:
mode:
Diffstat (limited to 'editors')
-rw-r--r--editors/ed.c19
-rw-r--r--editors/sed.c2
2 files changed, 4 insertions, 17 deletions
diff --git a/editors/ed.c b/editors/ed.c
index 9ce8bead1..516b8d78d 100644
--- a/editors/ed.c
+++ b/editors/ed.c
@@ -454,11 +454,7 @@ static void subCommand(const char *cmd, int num1, int num2)
454 * structure and use that. Link it in in place of 454 * structure and use that. Link it in in place of
455 * the old line structure. 455 * the old line structure.
456 */ 456 */
457 nlp = malloc(sizeof(LINE) + lp->len + deltaLen); 457 nlp = xmalloc(sizeof(LINE) + lp->len + deltaLen);
458 if (nlp == NULL) {
459 bb_error_msg("can't get memory for line");
460 return;
461 }
462 458
463 nlp->len = lp->len + deltaLen; 459 nlp->len = lp->len + deltaLen;
464 460
@@ -712,12 +708,7 @@ static int readLines(const char *file, int num)
712 708
713 if (bufUsed >= bufSize) { 709 if (bufUsed >= bufSize) {
714 len = (bufSize * 3) / 2; 710 len = (bufSize * 3) / 2;
715 cp = realloc(bufBase, len); 711 cp = xrealloc(bufBase, len);
716 if (cp == NULL) {
717 bb_error_msg("no memory for buffer");
718 close(fd);
719 return FALSE;
720 }
721 bufBase = cp; 712 bufBase = cp;
722 bufPtr = bufBase + bufUsed; 713 bufPtr = bufBase + bufUsed;
723 bufSize = len; 714 bufSize = len;
@@ -872,11 +863,7 @@ static int insertLine(int num, const char *data, int len)
872 return FALSE; 863 return FALSE;
873 } 864 }
874 865
875 newLp = malloc(sizeof(LINE) + len - 1); 866 newLp = xmalloc(sizeof(LINE) + len - 1);
876 if (newLp == NULL) {
877 bb_error_msg("failed to allocate memory for line");
878 return FALSE;
879 }
880 867
881 memcpy(newLp->data, data, len); 868 memcpy(newLp->data, data, len);
882 newLp->len = len; 869 newLp->len = len;
diff --git a/editors/sed.c b/editors/sed.c
index 19e768355..fd9dd1be6 100644
--- a/editors/sed.c
+++ b/editors/sed.c
@@ -1094,7 +1094,7 @@ static void process_files(void)
1094 /* append next_line, read new next_line. */ 1094 /* append next_line, read new next_line. */
1095 } 1095 }
1096 len = strlen(pattern_space); 1096 len = strlen(pattern_space);
1097 pattern_space = realloc(pattern_space, len + strlen(next_line) + 2); 1097 pattern_space = xrealloc(pattern_space, len + strlen(next_line) + 2);
1098 pattern_space[len] = '\n'; 1098 pattern_space[len] = '\n';
1099 strcpy(pattern_space + len+1, next_line); 1099 strcpy(pattern_space + len+1, next_line);
1100 last_gets_char = next_gets_char; 1100 last_gets_char = next_gets_char;