🚀 go-pugleaf

RetroBBS NetNews Server

Inspired by RockSolid Light RIP Retro Guy

Article View: gnu.emacs.bug
Article #706

Bug in etags building up the TEXTAGS table

#706
From: Geoff Oakley
Date: Tue, 18 Aug 1992 21:49
68 lines
2596 bytes
There is an apparent bug in etags in building up the TEXTAGS table.

The source file etags.c includes:

++  /* Default set of control sequences to put into TEX_toktab.
++     The value of environment var TEXTAGS is prepended to this.  */
++  
++  static char *TEX_defenv =
++    ":chapter:section:subsection:subsubsection:eqno:label:ref:cite:bibitem:typeout";
++  
  
    [ stuff ommitted ]
  
++  
++    /* Append deafult string to environment. */
++    env = (char *) getenv (evarname);
++    if (!env)
++      env = defenv;
++    else
++      env = concat (env, defenv, "");
++  
++    /* Allocate a token table */
++    for (size = 1, p=env; p;)
++      if ((p = index (p, ':')) && *(++p))
++        size++;
++    tab = (struct TEX_tabent *) xmalloc (size * sizeof (struct TEX_tabent));
++  
++    /* Unpack environment string into token table. Be careful about */
++    /* zero-length strings (leading ':', "::" and trailing ':') */
++    for (i = 0; *env;)
++      {
++        p = index (env, ':');
++        if (!p)			/* End of environment string. */
++  	    p = env + strlen (env);
++        if (p - env > 0)
++  	    {	/* Only non-zero strings. */
++  	      tab[i].name = savenstr (env, p - env);
++  	      tab[i].len = strlen (tab[i].name);
++  	      i++;
++  	    }
++        if (*p)
++  	    env = p + 1;
++        else
++  	    {
++  	      tab[i].name = NULL;	/* Mark end of table. */
++  	      tab[i].len = 0;
++  	      break;
++  	    }
++      }


Now, `size' is calculated to the one more that the number of colons in
`env'.  If the environment variable TEXTAGS contains a real string,
then the number of tags in the resulting `env' is also one more than
the number of colons (ie, number-of-tags=`size').  All these tags are
added to the table, filling the table up, but a final NULL entry is
then added to terminate the table.  This overfills the table and can
cause trashed memory.

A solution is to increment size (by one more).


Geoff O


	       geoffo@spectrum.cs.unsw.oz.au
Geoff Oakley:  CS & E, UNSW, PO Box 1, Kensington, NSW 2033, Australia
	       Phone: +61 2 697 4043	Fax: +61 2 313 7987
Technical Details
Message-ID: <920818014932.26278@cs.unsw.oz.au>
Path: arc1-ca.pugleaf.net!sparky!uunet!cis.ohio-state.edu!cs.unsw.oz.AU!geoffo

Show Full Headers
Complete Article Headers
Newsgroups: gnu.emacs.bug
Path: arc1-ca.pugleaf.net!sparky!uunet!cis.ohio-state.edu!cs.unsw.oz.AU!geoffo
From: geoffo@cs.unsw.oz.AU (Geoff Oakley)
Subject: Bug in etags building up the TEXTAGS table
Message-ID: <920818014932.26278@cs.unsw.oz.au>
Sender: gnulists@ai.mit.edu
Organization: GNUs Not Usenet
Distribution: gnu
Date: Tue, 18 Aug 1992 21:49:32 GMT
Approved: bug-gnu-emacs@prep.ai.mit.edu
Lines: 69