input: do not crash if sctofunc() returns NULL
This fixes a regression introduced by commit 54103d8e: a crash that can be triggered by running 'nano --restrict' and pressing <Insert>. This addresses https://bugzilla.redhat.com/1558532.master
parent
3e5b0ea5fd
commit
b830a7dd38
10
src/nano.c
10
src/nano.c
|
@ -1727,10 +1727,13 @@ int do_input(bool allow_funcs)
|
||||||
if (shortcut == NULL)
|
if (shortcut == NULL)
|
||||||
pletion_line = NULL;
|
pletion_line = NULL;
|
||||||
else {
|
else {
|
||||||
if (ISSET(VIEW_MODE) && !sctofunc(shortcut)->viewok) {
|
if (ISSET(VIEW_MODE)) {
|
||||||
|
const subnfunc *f = sctofunc(shortcut);
|
||||||
|
if (f && !f->viewok) {
|
||||||
print_view_warning();
|
print_view_warning();
|
||||||
return ERR;
|
return ERR;
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
/* If the function associated with this shortcut is
|
/* If the function associated with this shortcut is
|
||||||
* cutting or copying text, remember this. */
|
* cutting or copying text, remember this. */
|
||||||
|
@ -1801,8 +1804,11 @@ int do_input(bool allow_funcs)
|
||||||
wrap_reset();
|
wrap_reset();
|
||||||
#endif
|
#endif
|
||||||
#ifdef ENABLE_COLOR
|
#ifdef ENABLE_COLOR
|
||||||
if (!refresh_needed && !sctofunc(shortcut)->viewok)
|
if (!refresh_needed) {
|
||||||
|
const subnfunc *f = sctofunc(shortcut);
|
||||||
|
if (f && !f->viewok)
|
||||||
check_the_multis(openfile->current);
|
check_the_multis(openfile->current);
|
||||||
|
}
|
||||||
#endif
|
#endif
|
||||||
if (!refresh_needed && (shortcut->func == do_delete ||
|
if (!refresh_needed && (shortcut->func == do_delete ||
|
||||||
shortcut->func == do_backspace))
|
shortcut->func == do_backspace))
|
||||||
|
|
Loading…
Reference in New Issue