forked from mirrors/tftp-hpa-google
Add support for freeing a remap file datastructure, so we avoid a
memory leak.
This commit is contained in:
parent
519eb0ba91
commit
e3570e4d31
3 changed files with 26 additions and 3 deletions
|
@ -239,6 +239,26 @@ struct rule *parserulefile(FILE *f)
|
|||
return first_rule;
|
||||
}
|
||||
|
||||
/* Destroy a rule file data structure */
|
||||
void freerules(struct rule *r)
|
||||
{
|
||||
struct rule *next;
|
||||
|
||||
while ( r ) {
|
||||
next = r->next;
|
||||
|
||||
regfree(&r->rx);
|
||||
|
||||
/* "" patterns aren't allocated by malloc() */
|
||||
if ( r->pattern && *r->pattern )
|
||||
free(r->pattern);
|
||||
|
||||
free(r);
|
||||
|
||||
r = next;
|
||||
}
|
||||
}
|
||||
|
||||
/* Execute a rule set on a string; returns a malloc'd new string. */
|
||||
char *rewrite_string(const char *input, const struct rule *rules, int is_put)
|
||||
{
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue