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

Bug#541160: #541160 xterm: heap corruption when changing window size



On Thu, Aug 13, 2009 at 02:17:55AM +0200, Jan Christoph Nordholz wrote:
> Hi Thomas,
> 
> > This one is hard to reproduce (here).  valgrind is not showing me any
> > problems as I resize the screen in various ways.
> > 
> > There are several special cases in the resizing logic, depending on
> > resource-settings, as well as the amount of text that has been scrolled
> > off onto the saved-lines buffer.
> > 
> > More details would be helpful...
> 
> while Julien has uploaded a new xterm package with fifo-lines disabled,
> I can still help debugging the actual problem if this is desired. I
> can reliably reproduce the problem with an empty (i.e. freshly started)
> xterm with a bare prompt - once the buffer is full I can no longer make
> it crash. My .Xresources only contains modifications to the font settings.
> 
> I'll do a few valgrind runs myself and report back.

Here's a fix for the positioning problem that I've been seeing (attached).

-- 
Thomas E. Dickey <dickey@invisible-island.net>
http://invisible-island.net
ftp://invisible-island.net
===================================================================
RCS file: RCS/screen.c,v
retrieving revision 1.388
retrieving revision 1.389
diff -u -r1.388 -r1.389
--- screen.c	2009/08/07 23:20:07	1.388
+++ screen.c	2009/08/13 00:30:01	1.389
@@ -1,4 +1,4 @@
-/* $XTermId: screen.c,v 1.388 2009/08/07 23:20:07 tom Exp $ */
+/* $XTermId: screen.c,v 1.389 2009/08/13 00:30:01 tom Exp $ */
 
 /*
  * Copyright 1999-2008,2009 by Thomas E. Dickey
@@ -1787,8 +1787,17 @@
 		    ScrnBuf dst = screen->saveBuf_index;
 
 #if OPT_FIFO_LINES
-		    /* move line-data from visible-buffer to save-buffer */
-		    saveEditBufLines(screen, dst, move_up);
+		    int amount = ((MaxRows(screen) - (int) move_up - 1)
+				  - screen->cur_row);
+
+		    if (amount < 0) {
+			/* move line-data from visible-buffer to save-buffer */
+			saveEditBufLines(screen, dst, -amount);
+			move_up = -amount;
+			move_down_by = amount;
+		    } else {
+			move_down_by = 0;
+		    }
 #else /* !OPT_FIFO_LINES */
 		    int amount = screen->savelines - (int) move_up;
 
@@ -1898,6 +1907,7 @@
 
 		    /* copy line-data from save-buffer to visible-buffer */
 		    unsaveEditBufLines(screen, dst, move_down);
+		    TRACE_SCRNBUF("copied", screen, dst, rows);
 
 #if OPT_FIFO_LINES
 		    unsave_fifo = (long) move_down;

Attachment: signature.asc
Description: Digital signature


Reply to: