[net.bugs.4bsd] Yet another curses bug

laman@sdcsvax.UUCP (Mike Laman) (11/14/83)

    The following bug is in the curses library distributed over net.sources,
and in the 4.2 BSD distribution (that sdcsvax received at least).

    The bug is in makech() (in refresh.c).  makech() gets called to give
output for the given LINE (hint hint).  It is interesting that this bug
managed to get out.  Here is the offending code (the simple fix follows).

			:
			:
			:
		else if (wx < lch)
			while (*nsp == *csp) {
				nsp++;
				if (!curwin)
					csp++;
				++wx;
			}
		else
			:
			:
			:

I wrote a program that added '*' to (0, 0) on stdscr then a refresh().
wx ended up with a value of over 3000!  That loop walked down the line
and the next, ... (all the way down the window!).  The following code
is the fix.  Notice that the ++wx looks just perfect.  It really makes one
think "they" thought of it, but merely forgot to add the test.

			:
			:
			:
		else if (wx < lch)
			while (*nsp == *csp && wx <= lch) {
				nsp++;
				if (!curwin)
					csp++;
				++wx;
			}
		else
			:
			:
			:

			Mike Laman
			UUCP: {ucbvax,philabs,sdccsu3,sdcsla}!sdcsvax!laman