sgml-lex

Simon Watfa (simonw@quadrus.com)
Thu, 25 Jan 1996 21:01:28 -0700


Message-Id: <01BAEB69.31095AA0@cadc140.cadvision.com>
From: Simon Watfa <simonw@quadrus.com>
To: "'www-html@w3.org'" <www-html@w3.org>
Subject: sgml-lex
Date: Thu, 25 Jan 1996 21:01:28 -0700

Someone may have already pointed this out, but I thought it would be =
good to report this anyway.

I am using the flex-generated lexer "A Lexical Analyzer for HTML and =
Basic SGML" discussed
in "http://www.w3.org/pub/WWW/MarkUp/SGML/sgml-lex/sgml-lex.html" and =
have found that
it causes memory leaks.

The function in question is located in sgml_lex.c.  The following is an =
excerpt from that file.
There is a line missing in function freeEvent() which causes a memory =
leak.

	/* $Id: sgml_lex.c,v 1.5 1995/10/18 05:35:46 connolly Exp $ */=0A=
=0A=
	/*=0A=
	 * Implementation of Basic SGML lexer.=0A=
	 * For theory of operation, see W3C tech report:=0A=
	 *=0A=
	 *   "A Lexical Analyzer for HTML and Basic SGML"=0A=
	 *   http://www.w3.org/team/WWW/MarkUp/SGML/sgml-lex/sgml-lex.html=0A=

	[*** intermediate code omitted ***]

	static void=0A=
	freeEvent(SGML_Lexer *l)=0A=
	{=0A=
	  int i;=0A=
=0A=
	  for(i =3D 0; i < l->qty; i++){=0A=
	    free((char*) (l->strings)[i]);=0A=
	  }=0A=
	  free(l->strings); l->strings =3D NULL;=0A=
	  free(l->lengths); l->lengths =3D NULL;=0A=
	  free(l->types); l->types =3D NULL;		/*** THIS LINE IS MISSING IN =
ORIGINAL ***/
	=0A=
	  l->qty =3D 0;=0A=
	}=0A=