diff options
author | Denys Vlasenko <vda.linux@googlemail.com> | 2013-10-30 10:22:47 +0100 |
---|---|---|
committer | Denys Vlasenko <vda.linux@googlemail.com> | 2013-10-30 10:22:47 +0100 |
commit | 9d46a7a9a4d70756bab24de96221bd3a44ef8f46 (patch) | |
tree | eca30f6edf6aff93ad13e11760ed60f10a1d4222 | |
parent | af0cdeedc699da96e2f38c3f321150cdaa3bb7d6 (diff) | |
download | busybox-w32-9d46a7a9a4d70756bab24de96221bd3a44ef8f46.tar.gz busybox-w32-9d46a7a9a4d70756bab24de96221bd3a44ef8f46.tar.bz2 busybox-w32-9d46a7a9a4d70756bab24de96221bd3a44ef8f46.zip |
sed: fix memory leak in 'r FILE' command
Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
-rw-r--r-- | editors/sed.c | 7 |
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) | |||
848 | 848 | ||
849 | static void append(char *s) | 849 | static void append(char *s) |
850 | { | 850 | { |
851 | llist_add_to_end(&G.append_head, xstrdup(s)); | 851 | llist_add_to_end(&G.append_head, s); |
852 | } | 852 | } |
853 | 853 | ||
854 | static void flush_append(void) | 854 | static void flush_append(void) |
@@ -1181,7 +1181,7 @@ static void process_files(void) | |||
1181 | 1181 | ||
1182 | /* Append line to linked list to be printed later */ | 1182 | /* Append line to linked list to be printed later */ |
1183 | case 'a': | 1183 | case 'a': |
1184 | append(sed_cmd->string); | 1184 | append(xstrdup(sed_cmd->string)); |
1185 | break; | 1185 | break; |
1186 | 1186 | ||
1187 | /* Insert text before this line */ | 1187 | /* Insert text before this line */ |
@@ -1203,11 +1203,10 @@ static void process_files(void) | |||
1203 | rfile = fopen_for_read(sed_cmd->string); | 1203 | rfile = fopen_for_read(sed_cmd->string); |
1204 | if (rfile) { | 1204 | if (rfile) { |
1205 | char *line; | 1205 | char *line; |
1206 | |||
1207 | while ((line = xmalloc_fgetline(rfile)) | 1206 | while ((line = xmalloc_fgetline(rfile)) |
1208 | != NULL) | 1207 | != NULL) |
1209 | append(line); | 1208 | append(line); |
1210 | xprint_and_close_file(rfile); | 1209 | fclose(rfile); |
1211 | } | 1210 | } |
1212 | 1211 | ||
1213 | break; | 1212 | break; |