sgml-lex

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 $ */

	/*
	 * Implementation of Basic SGML lexer.
	 * For theory of operation, see W3C tech report:
	 *
	 *   "A Lexical Analyzer for HTML and Basic SGML"
	 *   http://www.w3.org/team/WWW/MarkUp/SGML/sgml-lex/sgml-lex.html

	[*** intermediate code omitted ***]

	static void
	freeEvent(SGML_Lexer *l)
	{
	  int i;

	  for(i = 0; i < l->qty; i++){
	    free((char*) (l->strings)[i]);
	  }
	  free(l->strings); l->strings = NULL;
	  free(l->lengths); l->lengths = NULL;
	  free(l->types); l->types = NULL;		/*** THIS LINE IS MISSING IN ORIGINAL ***/
	
	  l->qty = 0;
	}

Received on Thursday, 25 January 1996 23:10:21 UTC