[net.bugs.4bsd] newwin

rlb (07/31/82)

In the curses package in 4.1bsd, the newwin routine allocates storage
for a new window and initializes the fields in the window structure.
newwin() uses calloc() for most of the allocation, which guarantees
that the allocated storage will be zeroed.  However, it uses malloc()
for the window structure itself and malloc doesn't guarantee zeroes.

The problem is with the _flag field in the structure - it's a bit
vector.  The only operations on that field are oring in and anding
out bits - never is the field ever initialized to zero.  This causes
problems if the allocated word for the _flag field has STANDOUT or
other bothersome bits turned on initially.

FIX: insert the following line immediately after the call to malloc
in makenew() in newwin.c:

	win->_flags = 0

Bob Brown (rlb)
Purdue-CS (317) 494-6530

mark (07/31/82)

A better fix is to change all the malloc's to callocs.  Be sure to
insert an extra parameter of "1", since calloc wants two parameters.