diff options
author | Denys Vlasenko <vda.linux@googlemail.com> | 2018-09-25 12:50:54 +0200 |
---|---|---|
committer | Denys Vlasenko <vda.linux@googlemail.com> | 2018-09-25 12:50:54 +0200 |
commit | 706a9a03bb0a745a1f2db1ed632542a2d2af6021 (patch) | |
tree | c42e581099e16c2f4111d529f22d832211fd90f2 | |
parent | 76832ff5c4f107f8a8165fcafc9b05a888cdb964 (diff) | |
download | busybox-w32-706a9a03bb0a745a1f2db1ed632542a2d2af6021.tar.gz busybox-w32-706a9a03bb0a745a1f2db1ed632542a2d2af6021.tar.bz2 busybox-w32-706a9a03bb0a745a1f2db1ed632542a2d2af6021.zip |
sed: fix double-free in FEATURE_CLEAN_UP code
Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
-rw-r--r-- | editors/sed.c | 29 |
1 files changed, 17 insertions, 12 deletions
diff --git a/editors/sed.c b/editors/sed.c index 470220859..1054c1302 100644 --- a/editors/sed.c +++ b/editors/sed.c | |||
@@ -180,18 +180,23 @@ static void sed_free_and_close_stuff(void) | |||
180 | if (sed_cmd->sw_file) | 180 | if (sed_cmd->sw_file) |
181 | fclose(sed_cmd->sw_file); | 181 | fclose(sed_cmd->sw_file); |
182 | 182 | ||
183 | if (sed_cmd->beg_match) { | 183 | /* Used to free regexps, but now there is code |
184 | regfree(sed_cmd->beg_match); | 184 | * in get_address() which can reuse a regexp |
185 | free(sed_cmd->beg_match); | 185 | * for constructs as /regexp/cmd1;//cmd2 |
186 | } | 186 | * leading to double-frees here: |
187 | if (sed_cmd->end_match) { | 187 | */ |
188 | regfree(sed_cmd->end_match); | 188 | //if (sed_cmd->beg_match) { |
189 | free(sed_cmd->end_match); | 189 | // regfree(sed_cmd->beg_match); |
190 | } | 190 | // free(sed_cmd->beg_match); |
191 | if (sed_cmd->sub_match) { | 191 | //} |
192 | regfree(sed_cmd->sub_match); | 192 | //if (sed_cmd->end_match) { |
193 | free(sed_cmd->sub_match); | 193 | // regfree(sed_cmd->end_match); |
194 | } | 194 | // free(sed_cmd->end_match); |
195 | //} | ||
196 | //if (sed_cmd->sub_match) { | ||
197 | // regfree(sed_cmd->sub_match); | ||
198 | // free(sed_cmd->sub_match); | ||
199 | //} | ||
195 | free(sed_cmd->string); | 200 | free(sed_cmd->string); |
196 | free(sed_cmd); | 201 | free(sed_cmd); |
197 | sed_cmd = sed_cmd_next; | 202 | sed_cmd = sed_cmd_next; |