[PATCH] Fix a crash when F11 is pressed in editor with no filename



Hi

If you start an editor with no filename ("mc -e") and press F11, it 
crashes on NULL pointer dereference. This patch fixes the crash.

Mikulas

Index: mc-4.8.6-test/src/filemanager/usermenu.c
===================================================================
--- mc-4.8.6-test.orig/src/filemanager/usermenu.c
+++ mc-4.8.6-test/src/filemanager/usermenu.c
@@ -243,8 +243,13 @@ test_condition (WEdit * edit_widget, cha
                 char *edit_filename;
 
                 edit_filename = edit_get_file_name (edit_widget);
-                *condition = mc_search (arg, edit_filename, search_type) ? 1 : 0;
-                g_free (edit_filename);
+                if (edit_filename)
+                {
+                    *condition = mc_search (arg, edit_filename, search_type) ? 1 : 0;
+                    g_free (edit_filename);
+                }
+                else
+                    *condition = 0;
             }
             else
 #endif


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