summaryrefslogtreecommitdiff
path: root/lib/command.c
diff options
context:
space:
mode:
authorLou Berger <lberger@labn.net>2016-12-17 13:26:03 -0500
committerLou Berger <lberger@labn.net>2017-01-02 15:04:47 -0500
commit271a0c25483ae2072427557d0207e0e642a9ba04 (patch)
treec5d25221c188222b01c248418e7af83615b2a5e6 /lib/command.c
parent53a7a0651975a325ce56d7933aeab467f193bb65 (diff)
lib/command.c: fix leak id'ed by valgrind
Signed-off-by: Lou Berger <lberger@labn.net>
Diffstat (limited to 'lib/command.c')
-rw-r--r--lib/command.c28
1 files changed, 17 insertions, 11 deletions
diff --git a/lib/command.c b/lib/command.c
index 0b0614b806..0cabe32e6c 100644
--- a/lib/command.c
+++ b/lib/command.c
@@ -1066,6 +1066,7 @@ cmd_ipv6_prefix_match (const char *str)
const char *delim = "/\0";
char *dupe, *prefix, *mask, *context, *endptr;
int nmask = -1;
+ enum match_type ret;
if (str == NULL)
return partly_match;
@@ -1079,21 +1080,26 @@ cmd_ipv6_prefix_match (const char *str)
prefix = strtok_r(dupe, delim, &context);
mask = strtok_r(NULL, delim, &context);
+ ret = exact_match;
if (!mask)
- return partly_match;
-
- /* validate prefix */
- if (inet_pton(AF_INET6, prefix, &sin6_dummy.sin6_addr) != 1)
- return no_match;
-
- /* validate mask */
- nmask = strtol (mask, &endptr, 10);
- if (*endptr != '\0' || nmask < 0 || nmask > 128)
- return no_match;
+ ret = partly_match;
+ else
+ {
+ /* validate prefix */
+ if (inet_pton(AF_INET6, prefix, &sin6_dummy.sin6_addr) != 1)
+ ret = no_match;
+ else
+ {
+ /* validate mask */
+ nmask = strtol (mask, &endptr, 10);
+ if (*endptr != '\0' || nmask < 0 || nmask > 128)
+ ret = no_match;
+ }
+ }
XFREE(MTYPE_TMP, dupe);
- return exact_match;
+ return ret;
}
#endif /* HAVE_IPV6 */