Simon Watfa (
Thu, 25 Jan 1996 21:01:28 -0700

Message-Id: <>
From: Simon Watfa <>
To: "''" <>
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 "" 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 =

	/* $Id: sgml_lex.c,v 1.5 1995/10/18 05:35:46 connolly Exp $ */=0A=
	 * Implementation of Basic SGML lexer.=0A=
	 * For theory of operation, see W3C tech report:=0A=
	 *   "A Lexical Analyzer for HTML and Basic SGML"=0A=

	[*** intermediate code omitted ***]

	static void=0A=
	freeEvent(SGML_Lexer *l)=0A=
	  int i;=0A=
	  for(i =3D 0; i < l->qty; i++){=0A=
	    free((char*) (l->strings)[i]);=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 =
	  l->qty =3D 0;=0A=