1
0
mirror of https://git.openwrt.org/openwrt/openwrt.git synced 2024-11-18 22:43:53 +01:00
openwrt/package/busybox/patches/480-vi_search.patch
Mike Baker a75c1c1262 fix a null pointer deref in vi's search
SVN-Revision: 13073
2008-10-29 13:46:28 +00:00

36 lines
914 B
Diff

--- a/editors/vi.c
+++ b/editors/vi.c
@@ -3313,7 +3313,7 @@
buf[1] = '\0';
q = get_input_line(buf); // get input line- use "status line"
if (q[0] && !q[1]) {
- if (last_search_pattern[0])
+ if (last_search_pattern)
last_search_pattern[0] = c;
goto dc3; // if no pat re-use old pat
}
@@ -3329,6 +3329,10 @@
if (cmdcnt-- > 1) {
do_cmd(c);
} // repeat cnt
+ if (last_search_pattern == 0) {
+ msg = "No previous regular expression";
+ goto dc2;
+ }
dir = BACK; // assume BACKWARD search
p = dot - 1;
if (last_search_pattern[0] == '?') {
@@ -3348,10 +3352,8 @@
msg = "No previous regular expression";
goto dc2;
}
- if (last_search_pattern[0] == '/') {
- dir = FORWARD; // assume FORWARD search
- p = dot + 1;
- }
+ dir = FORWARD; // assume FORWARD search
+ p = dot + 1;
if (last_search_pattern[0] == '?') {
dir = BACK;
p = dot - 1;