diff options
| author | Quentin Young <qlyoung@cumulusnetworks.com> | 2016-09-08 21:07:55 +0000 |
|---|---|---|
| committer | Quentin Young <qlyoung@cumulusnetworks.com> | 2016-09-08 21:07:55 +0000 |
| commit | fe2e10e8d85990079da100fa0e2646a436cf3602 (patch) | |
| tree | 05bf0d9166cebe6c816e3f4cda3d6d25dab28792 /lib/grammar_sandbox.c | |
| parent | ff35126c0661e4b869f3c4782c02605a7f226e18 (diff) | |
lib: Fix uninitialized pointer segfault
Signed-off-by: Quentin Young <qlyoung@cumulusnetworks.com>
Diffstat (limited to 'lib/grammar_sandbox.c')
| -rw-r--r-- | lib/grammar_sandbox.c | 12 |
1 files changed, 9 insertions, 3 deletions
diff --git a/lib/grammar_sandbox.c b/lib/grammar_sandbox.c index fe01c113d2..6a783a6d56 100644 --- a/lib/grammar_sandbox.c +++ b/lib/grammar_sandbox.c @@ -289,9 +289,15 @@ new_cmd_token (enum cmd_token_type_t type, char *text, char *desc) void del_cmd_token (struct cmd_token_t *token) { - XFREE (MTYPE_CMD_TOKENS, token->text); - XFREE (MTYPE_CMD_TOKENS, token->desc); - XFREE (MTYPE_CMD_TOKENS, token->arg); + if (!token) return; + + if (token->text) + XFREE (MTYPE_CMD_TOKENS, token->text); + if (token->desc) + XFREE (MTYPE_CMD_TOKENS, token->desc); + if (token->arg) + XFREE (MTYPE_CMD_TOKENS, token->arg); + XFREE (MTYPE_CMD_TOKENS, token); } |
