nano-devel
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[Nano-devel] [PATCH] do_input: do not crash if sctofunc() returns NULL


From: Kamil Dudka
Subject: [Nano-devel] [PATCH] do_input: do not crash if sctofunc() returns NULL
Date: Tue, 20 Mar 2018 16:49:34 +0100

This fixes a regression introduced by v2.9.3-39-g54103d8e.  The crash
can be triggered by running 'nano --restrict' and pushing the Insert
key.

Bug: https://bugzilla.redhat.com/1558532
---
 src/nano.c | 16 +++++++++++-----
 1 file changed, 11 insertions(+), 5 deletions(-)

diff --git a/src/nano.c b/src/nano.c
index 260784ce..678dc987 100644
--- a/src/nano.c
+++ b/src/nano.c
@@ -1727,9 +1727,12 @@ int do_input(bool allow_funcs)
        if (shortcut == NULL)
                pletion_line = NULL;
        else {
-               if (ISSET(VIEW_MODE) && !sctofunc(shortcut)->viewok) {
-                       print_view_warning();
-                       return ERR;
+               if (ISSET(VIEW_MODE)) {
+                       const subnfunc *f = sctofunc(shortcut);
+                       if (f && !f->viewok) {
+                               print_view_warning();
+                               return ERR;
+                       }
                }
 
                /* If the function associated with this shortcut is
@@ -1801,8 +1804,11 @@ int do_input(bool allow_funcs)
                                wrap_reset();
 #endif
 #ifdef ENABLE_COLOR
-                       if (!refresh_needed && !sctofunc(shortcut)->viewok)
-                               check_the_multis(openfile->current);
+                       if (!refresh_needed) {
+                               const subnfunc *f = sctofunc(shortcut);
+                               if (f && !f->viewok)
+                                       check_the_multis(openfile->current);
+                       }
 #endif
                        if (!refresh_needed && (shortcut->func == do_delete ||
                                                                        
shortcut->func == do_backspace))
-- 
2.14.3




reply via email to

[Prev in Thread] Current Thread [Next in Thread]