Subject: lib/17754: libform, FIELD *[] changed during/after attachment to FORM.
To: None <gnats-bugs@gnats.netbsd.org>
From: None <rtr@wasabisystems.com>
List: netbsd-bugs
Date: 07/30/2002 08:45:03
>Number:         17754
>Category:       lib
>Synopsis:       libform, FIELD *[] changed during/after attachment to FORM.
>Confidential:   no
>Severity:       non-critical
>Priority:       medium
>Responsible:    lib-bug-people
>State:          open
>Class:          sw-bug
>Submitter-Id:   net
>Arrival-Date:   Mon Jul 29 05:41:01 PDT 2002
>Closed-Date:
>Last-Modified:
>Originator:     Tyler Retzlaff
>Release:        NetBSD 1.6E
>Organization:
	Organization
>Environment:
System: NetBSD elysium 1.6E NetBSD 1.6E (elysium) #0: Mon Jul 29 10:12:05 EST 2002 rtr@elysium:/usr/src/sys/arch/i386/compile/elysium i386
Architecture: i386
Machine: i386
>Description:
	Array of FIELD items forced to be static in size as change/adding
	prevents re-use.

	Creating an array of field items using it to create a form, destroying
	the form adding a couple of field items to the array and creating 
	a new form fails.

	Something goes wrong during the call to new_form() in
	_formi_stitch_fields() in internals.c causing the new form creation
	to hang.

>How-To-Repeat:
	The following code displays the problem so long as it's compiled 
	with -DAFIELD.  Compiling without will show expected behavior.

int
main(int argc, char **argv)
{
        FORM *f;
        FIELD *fields[4];

        initscr();
        cbreak();
        noecho();

        fields[0] = new_field(1, 10, 0, 0, 0, 0);
        fields[1] = new_field(1, 10, 1, 0, 0, 0);
        fields[2] = NULL;

        set_field_buffer(fields[0], 0, "Foo");
        set_field_buffer(fields[1], 0, "Bar");

        /* create form and display it */
        f = new_form(fields);
        set_form_sub(f, stdscr);
        post_form(f);
        refresh();
        sleep(2);  

        /* hide and destroy old form */
        unpost_form(f);
        refresh();
        free_form(f);
        sleep(1);

        /* create and display again using old fields */
#ifdef AFIELD
        fields[2] = new_field(1, 10, 2, 0, 0, 0);
        set_field_buffer(fields[2], 0, "Baby");
        fields[3] = NULL;
#endif
        f = new_form(fields);
        set_form_sub(f, stdscr);
        post_form(f);
        refresh();
        sleep(5);

        endwin();
}

>Fix:
	None
>Release-Note:
>Audit-Trail:
>Unformatted: