diff options
author | Denis Vlasenko <vda.linux@googlemail.com> | 2008-10-29 00:58:04 +0000 |
---|---|---|
committer | Denis Vlasenko <vda.linux@googlemail.com> | 2008-10-29 00:58:04 +0000 |
commit | c3a9dc8ac5b1938652ab1c48859d1cb71c6cbaa1 (patch) | |
tree | 7e270c83a1660de33dbfb2f22d19487de3cdfe82 | |
parent | 34e68c8b42ccbc8b04e6184f4985c3b47e6c6df0 (diff) | |
download | busybox-w32-c3a9dc8ac5b1938652ab1c48859d1cb71c6cbaa1.tar.gz busybox-w32-c3a9dc8ac5b1938652ab1c48859d1cb71c6cbaa1.tar.bz2 busybox-w32-c3a9dc8ac5b1938652ab1c48859d1cb71c6cbaa1.zip |
vi: fix uninitialized last_search_pattern (bug 5794)
-rw-r--r-- | editors/vi.c | 15 |
1 files changed, 5 insertions, 10 deletions
diff --git a/editors/vi.c b/editors/vi.c index 9960f7486..9f9a199fa 100644 --- a/editors/vi.c +++ b/editors/vi.c | |||
@@ -270,6 +270,7 @@ struct globals { | |||
270 | #define INIT_G() do { \ | 270 | #define INIT_G() do { \ |
271 | SET_PTR_TO_GLOBALS(xzalloc(sizeof(G))); \ | 271 | SET_PTR_TO_GLOBALS(xzalloc(sizeof(G))); \ |
272 | last_file_modified = -1; \ | 272 | last_file_modified = -1; \ |
273 | last_search_pattern = xzalloc(2); /* "" but has space for 2 chars */ \ | ||
273 | } while (0) | 274 | } while (0) |
274 | 275 | ||
275 | 276 | ||
@@ -2857,7 +2858,7 @@ static void do_cmd(int c) | |||
2857 | const char *msg = msg; // for compiler | 2858 | const char *msg = msg; // for compiler |
2858 | char *p, *q, *save_dot; | 2859 | char *p, *q, *save_dot; |
2859 | char buf[12]; | 2860 | char buf[12]; |
2860 | int dir = dir; // for compiler | 2861 | int dir; |
2861 | int cnt, i, j; | 2862 | int cnt, i, j; |
2862 | int c1; | 2863 | int c1; |
2863 | 2864 | ||
@@ -3196,7 +3197,7 @@ static void do_cmd(int c) | |||
3196 | q = get_input_line(buf); // get input line- use "status line" | 3197 | q = get_input_line(buf); // get input line- use "status line" |
3197 | if (q[0] && !q[1]) { | 3198 | if (q[0] && !q[1]) { |
3198 | if (last_search_pattern[0]) | 3199 | if (last_search_pattern[0]) |
3199 | last_search_pattern[0] = c; | 3200 | last_search_pattern[0] = c; |
3200 | goto dc3; // if no pat re-use old pat | 3201 | goto dc3; // if no pat re-use old pat |
3201 | } | 3202 | } |
3202 | if (q[0]) { // strlen(q) > 1: new pat- save it and find | 3203 | if (q[0]) { // strlen(q) > 1: new pat- save it and find |
@@ -3226,14 +3227,8 @@ static void do_cmd(int c) | |||
3226 | do_cmd(c); | 3227 | do_cmd(c); |
3227 | } // repeat cnt | 3228 | } // repeat cnt |
3228 | dc3: | 3229 | dc3: |
3229 | if (last_search_pattern == 0) { | 3230 | dir = FORWARD; // assume FORWARD search |
3230 | msg = "No previous regular expression"; | 3231 | p = dot + 1; |
3231 | goto dc2; | ||
3232 | } | ||
3233 | if (last_search_pattern[0] == '/') { | ||
3234 | dir = FORWARD; // assume FORWARD search | ||
3235 | p = dot + 1; | ||
3236 | } | ||
3237 | if (last_search_pattern[0] == '?') { | 3232 | if (last_search_pattern[0] == '?') { |
3238 | dir = BACK; | 3233 | dir = BACK; |
3239 | p = dot - 1; | 3234 | p = dot - 1; |