aboutsummaryrefslogtreecommitdiff
path: root/editors/ed.c
diff options
context:
space:
mode:
Diffstat (limited to 'editors/ed.c')
-rw-r--r--editors/ed.c19
1 files changed, 3 insertions, 16 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;