Browse Source

* screen.c (show_dir): A small fix to avoid a crash in show_dir() with
a panel of more than 200 columns.

Andrew V. Samoilov 20 years ago
parent
commit
358f13f13d
2 changed files with 11 additions and 2 deletions
  1. 5 0
      src/ChangeLog
  2. 6 2
      src/screen.c

+ 5 - 0
src/ChangeLog

@@ -1,3 +1,8 @@
+2004-11-04  Jindrich Novy  <jnovy@redhat.com>
+
+	* screen.c (show_dir): A small fix to avoid a crash in show_dir() with
+	a panel of more than 200 columns.
+
 2004-11-03  Andrew V. Samoilov  <sav@bcs.zp.ua>
 
 	* file.c (make_symlink): Use g_strlcpy() instead of strcpy().

+ 6 - 2
src/screen.c

@@ -728,7 +728,7 @@ mini_info_separator (WPanel *panel)
 static void
 show_dir (WPanel *panel)
 {
-    char tmp[200];
+    char *tmp;
 
     set_colors (panel);
     draw_double_box (panel->widget.parent,
@@ -750,9 +750,13 @@ show_dir (WPanel *panel)
 
     widget_move (&panel->widget, 0, 3);
 
+    tmp = g_malloc (panel->widget.cols + 1);
+    tmp[panel->widget.cols] = '\0';
+
     trim (strip_home_and_password (panel->cwd), tmp,
-	  max (panel->widget.cols - 7, 0));
+	 min (max (panel->widget.cols - 7, 0), panel->widget.cols) );
     addstr (tmp);
+    g_free (tmp);
     widget_move (&panel->widget, 0, 1);
     addstr ("<");
     widget_move (&panel->widget, 0, panel->widget.cols - 2);