summaryrefslogtreecommitdiff
path: root/sed.c
diff options
context:
space:
mode:
authorMatt Kraai2000-09-13 02:46:14 +0000
committerMatt Kraai2000-09-13 02:46:14 +0000
commit322ae93a5e0b78b65831f9fd87fd456eb84d21a1 (patch)
tree5b967e1d873ff6eff8296bf9fda73825f0c55884 /sed.c
parentb89075298edf0a471b9046b1f3c8a936e18ead20 (diff)
downloadbusybox-322ae93a5e0b78b65831f9fd87fd456eb84d21a1.zip
busybox-322ae93a5e0b78b65831f9fd87fd456eb84d21a1.tar.gz
Fix calls to {m,c,re}alloc so that they use x{m,c,re}alloc instead of
segfaulting or handling errors the same way themselves.
Diffstat (limited to 'sed.c')
-rw-r--r--sed.c5
1 files changed, 2 insertions, 3 deletions
diff --git a/sed.c b/sed.c
index f3c3262..0e0d7f5 100644
--- a/sed.c
+++ b/sed.c
@@ -44,7 +44,6 @@
*/
#include <stdio.h>
-#include <stdlib.h> /* for realloc() */
#include <unistd.h> /* for getopt() */
#include <regex.h>
#include <string.h> /* for strdup() */
@@ -457,7 +456,7 @@ static void add_cmd_str(const char *cmdstr)
continue;
}
/* grow the array */
- sed_cmds = realloc(sed_cmds, sizeof(struct sed_cmd) * (++ncmds));
+ sed_cmds = xrealloc(sed_cmds, sizeof(struct sed_cmd) * (++ncmds));
/* zero new element */
memset(&sed_cmds[ncmds-1], 0, sizeof(struct sed_cmd));
/* load command string into new array element, get remainder */
@@ -481,7 +480,7 @@ static void load_cmd_file(char *filename)
/* if a line ends with '\' it needs the next line appended to it */
while (line[strlen(line)-2] == '\\' &&
(nextline = get_line_from_file(cmdfile)) != NULL) {
- line = realloc(line, strlen(line) + strlen(nextline) + 1);
+ line = xrealloc(line, strlen(line) + strlen(nextline) + 1);
strcat(line, nextline);
free(nextline);
}