On Mon, Mar 05, 2001 at 02:18:44PM +0200, Marius Gedminas wrote:
> The current CVS version of rxvt segfaults when maximizing/resizing a
> window if the alternate screen is active.

The problem is in rxvt_resize_all_windows (main.c).  First it calculates
the new value of r->TermWin.nrow (line 948), then it calls
rxvt_scr_change_screen (line 983) which happily trashes memory by using
the new nrow value with old data structures.  (When the primary screen
is active, rxvt_scr_change_screen just returns without touching
anything).

A patch is attached.  I definitely wouldn't call it a proper bugfix, but
it works as a workaround.

Marius Gedminas
-- 
C is quirky, flawed, and an enormous success.
                -- Dennis M. Ritchie
Index: src/main.c
===================================================================
RCS file: /cvsroot/rxvt/rxvt/src/main.c,v
retrieving revision 1.142
diff -u -r1.142 main.c
--- src/main.c  2001/03/01 05:07:03     1.142
+++ src/main.c  2001/03/05 14:33:07
@@ -976,11 +976,16 @@
 
     if (fix_screen || r->h->old_height == 0) {
        int             curr_screen = -1;
+       int16_t         tmp;
 
        /* scr_reset only works on the primary screen */
        if (r->h->old_height) { /* this is not the first time through */
            rxvt_selection_clear(r);
+           SWAP_IT(r->TermWin.nrow, r->h->prev_nrow, tmp);
+           SWAP_IT(r->TermWin.ncol, r->h->prev_ncol, tmp);
            curr_screen = rxvt_scr_change_screen(r, PRIMARY);
+           SWAP_IT(r->TermWin.nrow, r->h->prev_nrow, tmp);
+           SWAP_IT(r->TermWin.ncol, r->h->prev_ncol, tmp);
        }
        rxvt_scr_reset(r);
        if (curr_screen >= 0)   /* this is not the first time through */

Reply via email to