Commit fd998c7d authored by Per Cederqvist's avatar Per Cederqvist
Browse files

(free_aux_item_definitions): Fixed a memory leak. We have to call

	regfree() to deallocate stuff within the compiled regular
	expression.  This bug was found with valgrind.
parent 476c8961
/*
* $Id: aux-items.c,v 1.41 2002/04/11 20:16:55 byers Exp $
* $Id: aux-items.c,v 1.42 2002/08/02 00:27:12 ceder Exp $
* Copyright (C) 1994-2001 Lysator Academic Computer Association.
*
* This file is part of the LysKOM server.
......@@ -444,7 +444,17 @@ aux_item_definition_cache_regexp(const Aux_item_definition *def,
def->tag,
def->name);
if (def->validators[ix].v.re.cached_re_buf)
{
#if 0
/* FIXME (bug 687): Do we need to regfree() the compiled
regexp here? Are we *allowed* to regfree() it? For
now, I'd rather have a small memory leak than a double
free() bug, so don't free it without checking what
re_compile_pattern actually does. */
regfree(def->validators[ix].v.re.cached_re_buf);
#endif
sfree(def->validators[ix].v.re.cached_re_buf);
}
if (def->validators[ix].v.re.regexp)
string_free(def->validators[ix].v.re.regexp);
def->validators[ix].v.re.cached_re_buf = NULL;
......@@ -491,7 +501,10 @@ free_aux_item_definitions(void)
if (def->validators[i].v.re.regexp != NULL)
string_free(def->validators[i].v.re.regexp);
if (def->validators[i].v.re.cached_re_buf != NULL)
{
regfree(def->validators[i].v.re.cached_re_buf);
sfree(def->validators[i].v.re.cached_re_buf);
}
}
}
if (def->validators != NULL)
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment