Re: show_dir crashes on more than 200 columns
- From: Leonard den Ottolander <leonard den ottolander nl>
- To: MC Devel <mc-devel gnome org>
- Subject: Re: show_dir crashes on more than 200 columns
- Date: Wed, 03 Nov 2004 15:05:27 +0100
Hi Pavel,
On Wed, 2004-11-03 at 12:50, Pavel Tsekov wrote:
> No, it is not. You cannot rely on MC_MAXPATHLEN - it can be too small or
> too big. For exmaple on Cygwin it is set to 259 . I remeber I've seen
> also pretty big values for MAXPATHLEN which are not suitable for
> allocating on the stack. Use the `widget.cols' and allocate memory from
> the heap.
Ok. Restored to original code from Jindrich. See attached patch.
Leonard.
--
mount -t life -o ro /dev/dna /genetic/research
--- screen.c.000 2004-09-26 00:02:15.000000000 +0200
+++ screen.c 2004-11-03 15:03:21.000000000 +0100
@@ -728,7 +728,8 @@ mini_info_separator (WPanel *panel)
static void
show_dir (WPanel *panel)
{
- char tmp[200];
+ char *tmp;
+ tmp = g_malloc0(MC_MAXPATHLEN);
set_colors (panel);
draw_double_box (panel->widget.parent,
@@ -751,8 +752,9 @@ show_dir (WPanel *panel)
widget_move (&panel->widget, 0, 3);
trim (strip_home_and_password (panel->cwd), tmp,
- max (panel->widget.cols - 7, 0));
+ min(max(panel->widget.cols - 7, 0), MC_MAXPATHLEN - 1));
addstr (tmp);
+ g_free (tmp);
widget_move (&panel->widget, 0, 1);
addstr ("<");
widget_move (&panel->widget, 0, panel->widget.cols - 2);
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]