aboutsummaryrefslogtreecommitdiff
path: root/editors
diff options
context:
space:
mode:
authorDenys Vlasenko <vda.linux@googlemail.com>2013-10-30 10:22:47 +0100
committerDenys Vlasenko <vda.linux@googlemail.com>2013-10-30 10:22:47 +0100
commit9d46a7a9a4d70756bab24de96221bd3a44ef8f46 (patch)
treeeca30f6edf6aff93ad13e11760ed60f10a1d4222 /editors
parentaf0cdeedc699da96e2f38c3f321150cdaa3bb7d6 (diff)
downloadbusybox-9d46a7a9a4d70756bab24de96221bd3a44ef8f46.tar.gz
sed: fix memory leak in 'r FILE' command
Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
Diffstat (limited to 'editors')
-rw-r--r--editors/sed.c7
1 files changed, 3 insertions, 4 deletions
diff --git a/editors/sed.c b/editors/sed.c
index ef462843b..e3cce433e 100644
--- a/editors/sed.c
+++ b/editors/sed.c
@@ -848,7 +848,7 @@ static sed_cmd_t *branch_to(char *label)
static void append(char *s)
{
- llist_add_to_end(&G.append_head, xstrdup(s));
+ llist_add_to_end(&G.append_head, s);
}
static void flush_append(void)
@@ -1181,7 +1181,7 @@ static void process_files(void)
/* Append line to linked list to be printed later */
case 'a':
- append(sed_cmd->string);
+ append(xstrdup(sed_cmd->string));
break;
/* Insert text before this line */
@@ -1203,11 +1203,10 @@ static void process_files(void)
rfile = fopen_for_read(sed_cmd->string);
if (rfile) {
char *line;
-
while ((line = xmalloc_fgetline(rfile))
!= NULL)
append(line);
- xprint_and_close_file(rfile);
+ fclose(rfile);
}
break;