> This is about a now-rather-old curses - [...]
> [...misbehaviour...]

It's a bug in curses; it assumes newly-malloc()ed memory is cleared in
a least one tiny respect (NONL in a new screen is uninitialized; in the
broken run, it ends up being -1 instead of 0).  Setting
MALLOC_OPTIONS=AJVX (my usual debugging setting) makes the "working"
command misbehave too; it appears to "work", when it does, because
something else has already grabbed the non-zeroed malloc()ed block, so
curses gets new memory.

Unfortunately this is the 5.2 curses, so it's not entirely trivial to
run it under my undefined-memory checking SPARC emulator.  I may try to
make it build there, or possibly on a work Linux machine where I can
use valgrind, to figure out whether there are other such issues.

This change makes the symptom go away for me:

--- a/lib/libcurses/screen.c
+++ b/lib/libcurses/screen.c
@@ -117,7 +117,7 @@ newterm(char *type, FILE *outfd, FILE *infd)
        if ((type == NULL) && (sp = getenv("TERM")) == NULL)
                return NULL;
 
-       if ((new_screen = (SCREEN *) malloc(sizeof(SCREEN))) == NULL)
+       if ((new_screen = (SCREEN *) calloc(sizeof(SCREEN),1)) == NULL)
                return NULL;
 
 #ifdef DEBUG

It obviously is not the *right* fix, but it's good enough for me for
the moment.

/~\ The ASCII                             Mouse
\ / Ribbon Campaign
 X  Against HTML                [email protected]
/ \ Email!           7D C8 61 52 5D E7 2D 39  4E F1 31 3E E8 B3 27 4B

Reply via email to