guy@gorodish.UUCP (03/25/87)
Index: usr.lib/libcurses/overwrite.c 4.3BSD
Description:
"overwrite" can drop core in some circumstances.
Repeat-By:
Run the following program:
# include <curses.h>
char junk[] = "junk";
char morjunk[] = "MORE JUNK";
main()
{
WINDOW *win, *swin, *twin;
int i, j;
initscr ();
noecho();
crmode();
twin = newwin(LINES,COLS,0,0);
wclear(twin);
for(i = 0; i < LINES - 1; i++)
for(j = 0; j < COLS - 1; j++)
mvwaddch(twin, i, j, 'A' + i);
wrefresh (twin);
getch();
win = newwin(LINES/2, COLS/2, 0, COLS/2);
swin = subwin(win, LINES/2-1, COLS/2-1, 1, COLS/2+1);
overwrite(twin, swin);
for(i = 1; i < LINES/2-2; i++)
for(j = 1; j < COLS/2-2; j++)
mvwaddch(win, i, j, morjunk[j % (sizeof(morjunk)-1)]);
touchwin(win);
wrefresh(win);
getch();
endwin();
}
It will paint the screen and stop. When it stops, hit RETURN
and watch it drop core.
Fix:
*** /arch/4.3/usr/src/usr.lib/libcurses/overwrite.c Fri Jun 7 11:39:28 1985
--- overwrite.c Tue Mar 24 20:05:06 1987
***************
*** 29,35 ****
# endif
starty = max(win1->_begy, win2->_begy);
startx = max(win1->_begx, win2->_begx);
! endy = min(win1->_maxy + win1->_begy, win2->_maxy + win2->_begx);
endx = min(win1->_maxx + win1->_begx, win2->_maxx + win2->_begx);
if (starty >= endy || startx >= endx)
return;
--- 29,35 ----
# endif
starty = max(win1->_begy, win2->_begy);
startx = max(win1->_begx, win2->_begx);
! endy = min(win1->_maxy + win1->_begy, win2->_maxy + win2->_begy);
endx = min(win1->_maxx + win1->_begx, win2->_maxx + win2->_begx);
if (starty >= endy || startx >= endx)
return;