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

Mikulas Patocka mikulas at artax.karlin.mff.cuni.cz
Fri Dec 7 01:12:54 UTC 2012


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



More information about the mc-devel mailing list