[patch] fix crash when cancelling the search dialog

2005-08-27 Thread Jindrich Makovicka
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 -  1.339
+++ view.c  27 Aug 2005 08:53:58 -
@@ -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
___
Mc-devel mailing list
http://mail.gnome.org/mailman/listinfo/mc-devel


Re: [patch] fix crash when cancelling the search dialog

2005-08-27 Thread Jindrich Novy
Hi Jindrich,

On Sat, 2005-08-27 at 10:56 +0200, Jindrich Makovicka wrote:
 @@ -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

This hunk is not needed as g_free() handles case of freeing NULL
pointer.

Jindrich

-- 
Jindrich Novy [EMAIL PROTECTED], http://people.redhat.com/jnovy/
(o_   _o)
//\  The worst evil in the world is refusal to think. //\
V_/_ _\_V


___
Mc-devel mailing list
http://mail.gnome.org/mailman/listinfo/mc-devel