diff options
author | Denys Vlasenko | 2018-09-25 12:50:54 +0200 |
---|---|---|
committer | Denys Vlasenko | 2018-09-25 12:50:54 +0200 |
commit | 706a9a03bb0a745a1f2db1ed632542a2d2af6021 (patch) | |
tree | c42e581099e16c2f4111d529f22d832211fd90f2 /editors | |
parent | 76832ff5c4f107f8a8165fcafc9b05a888cdb964 (diff) | |
download | busybox-706a9a03bb0a745a1f2db1ed632542a2d2af6021.zip busybox-706a9a03bb0a745a1f2db1ed632542a2d2af6021.tar.gz |
sed: fix double-free in FEATURE_CLEAN_UP code
Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
Diffstat (limited to 'editors')
-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 4702208..1054c13 100644 --- a/editors/sed.c +++ b/editors/sed.c @@ -180,18 +180,23 @@ static void sed_free_and_close_stuff(void) if (sed_cmd->sw_file) fclose(sed_cmd->sw_file); - if (sed_cmd->beg_match) { - regfree(sed_cmd->beg_match); - free(sed_cmd->beg_match); - } - if (sed_cmd->end_match) { - regfree(sed_cmd->end_match); - free(sed_cmd->end_match); - } - if (sed_cmd->sub_match) { - regfree(sed_cmd->sub_match); - free(sed_cmd->sub_match); - } + /* Used to free regexps, but now there is code + * in get_address() which can reuse a regexp + * for constructs as /regexp/cmd1;//cmd2 + * leading to double-frees here: + */ + //if (sed_cmd->beg_match) { + // regfree(sed_cmd->beg_match); + // free(sed_cmd->beg_match); + //} + //if (sed_cmd->end_match) { + // regfree(sed_cmd->end_match); + // free(sed_cmd->end_match); + //} + //if (sed_cmd->sub_match) { + // regfree(sed_cmd->sub_match); + // free(sed_cmd->sub_match); + //} free(sed_cmd->string); free(sed_cmd); sed_cmd = sed_cmd_next; |