[patch] fix crash when cancelling the search dialog



Hi,

when cancelling the search dialog in the viewer (F3, F7, ESC ESC), the
exp pointer is not allocated and mc occasionally crashes on free. The
attached patch fixes it.

-- 
Jindrich Makovicka
Index: view.c
===================================================================
RCS file: /cvsroot/mc/mc/src/view.c,v
retrieving revision 1.339
diff -u -r1.339 view.c
--- view.c	22 Aug 2005 19:19:51 -0000	1.339
+++ view.c	27 Aug 2005 08:53:58 -0000
@@ -2730,7 +2730,7 @@
 static void
 view_normal_search_cmd (WView *view)
 {
-    char *defval, *exp;
+    char *defval = NULL, *exp = NULL;
 
     enum {
 	SEARCH_DLG_HEIGHT = 8,
@@ -2787,8 +2787,8 @@
     view->last_search = do_normal_search;
 
 cleanup:
-    g_free (exp);
-    g_free (defval);
+    if (exp) g_free (exp);
+    if (defval) g_free (defval);
 }
 
 static void


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