On 2014-11-10 20:04 +0000, Nicholas Marriott wrote:
> I reverted the grid-view.c change because it breaks insertion. Try:
> $ tmux new 'tput ich 10'

Oh, sorry about that. What a silly mistake, the 4th parameter
underflows in grid_move_cells:

...
#1  0x000000000042a3f9 in log_fatal (msg=0x46e461 "%s: %s") at log.c:105
#2  0x0000000000458dba in xreallocarray (oldptr=0x0, nmemb=4294967286, size=14) 
at xmalloc.c:92
#3  0x000000000042073b in grid_expand_line (gd=0x1af9790, py=1, sx=4294967286) 
at grid.c:226
#4  0x0000000000420d89 in grid_move_cells (gd=0x1af9790, dx=10, px=0, py=1, 
nx=4294967286) at grid.c:381
#5  0x0000000000420182 in grid_view_insert_cells (gd=0x1af9790, px=0, py=1, 
nx=10) at grid-view.c:192
#6  0x0000000000432d14 in screen_write_insertcharacter (ctx=0x1af9528, nx=10) 
at screen-write.c:543
...

How about this as the bugfix:

diff --git a/grid-view.c b/grid-view.c
index 45737e3..39017c1 100644
--- a/grid-view.c
+++ b/grid-view.c
@@ -185,6 +185,8 @@ grid_view_insert_cells(struct grid *gd, u_int px, u_int py, 
u_int nx)
        py = grid_view_y(gd, py);
 
        sx = grid_view_x(gd, gd->linedata[py].cellsize);
+       if (sx < px + nx)
+               sx = px + nx;
 
        if (px == sx - 1)
                grid_clear(gd, px, py, 1, 1);
@@ -202,6 +204,8 @@ grid_view_delete_cells(struct grid *gd, u_int px, u_int py, 
u_int nx)
        py = grid_view_y(gd, py);
 
        sx = grid_view_x(gd, gd->linedata[py].cellsize);
+       if (sx < px + nx)
+               sx = px + nx;
 
        grid_move_cells(gd, px, px + nx, py, sx - px - nx);
        grid_clear(gd, sx - nx, py, px + nx - (sx - nx), 1);

-- 
Balazs

------------------------------------------------------------------------------
Comprehensive Server Monitoring with Site24x7.
Monitor 10 servers for $9/Month.
Get alerted through email, SMS, voice calls or mobile push notifications.
Take corrective actions from your mobile device.
http://pubads.g.doubleclick.net/gampad/clk?id=154624111&iu=/4140/ostg.clktrk
_______________________________________________
tmux-users mailing list
tmux-users@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/tmux-users

Reply via email to