diff options
Diffstat (limited to 'editors/sed.c')
-rw-r--r-- | editors/sed.c | 33 |
1 files changed, 15 insertions, 18 deletions
diff --git a/editors/sed.c b/editors/sed.c index 85eb9f68d..037d2a8ac 100644 --- a/editors/sed.c +++ b/editors/sed.c | |||
@@ -118,30 +118,27 @@ const char * const semicolon_whitespace = "; \n\r\t\v\0"; | |||
118 | #ifdef CONFIG_FEATURE_CLEAN_UP | 118 | #ifdef CONFIG_FEATURE_CLEAN_UP |
119 | static void destroy_cmd_strs(void) | 119 | static void destroy_cmd_strs(void) |
120 | { | 120 | { |
121 | if (sed_cmds == NULL) | 121 | sed_cmd_t *sed_cmd = sed_cmd_head.linear; |
122 | return; | ||
123 | 122 | ||
124 | /* destroy all the elements in the array */ | 123 | while (sed_cmd) { |
125 | while (--ncmds >= 0) { | 124 | sed_cmd_t *sed_cmd_next = sed_cmd->linear; |
126 | 125 | ||
127 | if (sed_cmds[ncmds]->beg_match) { | 126 | if (sed_cmd->beg_match) { |
128 | regfree(sed_cmds[ncmds]->beg_match); | 127 | regfree(sed_cmd->beg_match); |
129 | free(sed_cmds[ncmds]->beg_match); | 128 | free(sed_cmd->beg_match); |
130 | } | 129 | } |
131 | if (sed_cmds[ncmds]->end_match) { | 130 | if (sed_cmd->end_match) { |
132 | regfree(sed_cmds[ncmds]->end_match); | 131 | regfree(sed_cmd->end_match); |
133 | free(sed_cmds[ncmds]->end_match); | 132 | free(sed_cmd->end_match); |
134 | } | 133 | } |
135 | if (sed_cmds[ncmds]->sub_match) { | 134 | if (sed_cmd->sub_match) { |
136 | regfree(sed_cmds[ncmds]->sub_match); | 135 | regfree(sed_cmd->sub_match); |
137 | free(sed_cmds[ncmds]->sub_match); | 136 | free(sed_cmd->sub_match); |
138 | } | 137 | } |
139 | free(sed_cmds[ncmds]->replace); | 138 | free(sed_cmd->replace); |
139 | free(sed_cmd); | ||
140 | sed_cmd = sed_cmd_next; | ||
140 | } | 141 | } |
141 | |||
142 | /* destroy the array */ | ||
143 | free(sed_cmds); | ||
144 | sed_cmds = NULL; | ||
145 | } | 142 | } |
146 | #endif | 143 | #endif |
147 | 144 | ||