]> git.proxmox.com Git - mirror_frr.git/commit - lib/command_parse.y
lib: parser: fix memory management
authorDavid Lamparter <equinox@opensourcerouting.org>
Wed, 25 Jan 2017 01:27:29 +0000 (02:27 +0100)
committerDavid Lamparter <equinox@opensourcerouting.org>
Wed, 25 Jan 2017 01:27:29 +0000 (02:27 +0100)
commit83364d20d5667c3b43e1e672d2166c22b6fd8cf5
treec0e48ac257605cd47d80f79dcdd8a9555aaef322
parentac9ddce37d16af4e36c1ff945c12aaaf615e69d8
lib: parser: fix memory management

command.c had:
DEFINE_MTYPE_STATIC(LIB, CMD_TOKENS, "Command desc")
while command_match.c had:
DEFINE_MTYPE_STATIC(LIB, CMD_TOKENS, "Command Tokens")

... which means that there are 2 distinct MTYPE_CMD_TOKENS.
(The description text being different does not matter, even with the
same text it'd be 2 distinct types.)

command_match.c allocates token->arg in command_match_r() while
command.c frees it in del_cmd_token().  Therefore with each command
being executed, the allocation count goes up on one, down on the other.

=> clean up parser allocation counting.  Also, use separate MTYPEs for
the different fields in struct cmd_token.

Fixes: #108 / ee9216cf ("lib, ripngd: clean up merge leftovers")
Signed-off-by: David Lamparter <equinox@opensourcerouting.org>
Cc: Quentin Young <qlyoung@cumulusnetworks.com>
lib/command.c
lib/command.h
lib/command_match.c
lib/command_parse.y