[net.emacs] Bug in GNU Emacs 17.36 tputs

bruce@stride.UUCP (Bruce Robertson) (01/04/86)

There is a bug in the GNU Emacs 17.36 tputs() function that causes
garbage to be written to your screen, when your termcap entry does not
have the "im" (enter insert mode) and "ei" (exit insert mode)
capabilities.  This bug can quite probably affect other missing string
capabilities, too.

After doing a little research, I discovered that the routines in term.c
use the "im" and "ei" capabilities even if they weren't set when Emacs
started up.  This worked fine when GNU Emacs still used the normal termcap
library, because the normal tputs() routine exits immediately if it is
passed a null pointer.  The new tputs() provided in file termcap.c, however,
dereferences its pointer, null or otherwise.

Here is a context diff with the fix:

*** /usr/local/gnu/src/termcap.c.OLD	Fri Jan  3 22:04:46 1986
--- /usr/local/gnu/src/termcap.c	Fri Jan  3 22:04:50 1986
***************
*** 225,230
  {
    register int padcount = 0;
  
    while (*string >= '0' && *string <= '9')
      {
        padcount += *string++ - '0';

--- 225,232 -----
  {
    register int padcount = 0;
  
+   if (string == (char *) 0)
+     return;
    while (*string >= '0' && *string <= '9')
      {
        padcount += *string++ - '0';
-- 

	Bruce Robertson
	UUCP: cbosgd!utah-cs!utah-gr!stride!bruce