diff options
author | Jason A. Donenfeld <Jason@zx2c4.com> | 2018-06-17 05:13:22 +0200 |
---|---|---|
committer | Jason A. Donenfeld <Jason@zx2c4.com> | 2018-06-17 19:36:37 +0200 |
commit | bec4c48d89894eda860806a8e28166fcd236fa66 (patch) | |
tree | 2222ecb93a43a002b364706ea3aeffe3ae2171e1 /src/tools/wg-quick/android.c | |
parent | wg-quick: android: disable roaming to v6 networks when v4 is specified (diff) | |
download | wireguard-monolithic-historical-bec4c48d89894eda860806a8e28166fcd236fa66.tar.xz wireguard-monolithic-historical-bec4c48d89894eda860806a8e28166fcd236fa66.zip |
wg-quick: android: don't forget to free compiled regexes
Diffstat (limited to 'src/tools/wg-quick/android.c')
-rw-r--r-- | src/tools/wg-quick/android.c | 11 |
1 files changed, 6 insertions, 5 deletions
diff --git a/src/tools/wg-quick/android.c b/src/tools/wg-quick/android.c index 757f265..66e5b3f 100644 --- a/src/tools/wg-quick/android.c +++ b/src/tools/wg-quick/android.c @@ -120,6 +120,7 @@ static void fclosep(FILE **f) } #define _cleanup_free_ _cleanup_(freep) #define _cleanup_fclose_ _cleanup_(fclosep) +#define _cleanup_regfree_ _cleanup_(regfree) #define DEFINE_CMD(name) _cleanup_(free_command_buffer) struct command_buffer name = { 0 }; @@ -250,7 +251,7 @@ static void add_if(const char *iface) static void del_if(const char *iface) { DEFINE_CMD(c); - regex_t reg; + _cleanup_regfree_ regex_t reg = { 0 }; regmatch_t matches[2]; char *netid = NULL; _cleanup_free_ char *regex = concat("0xc([0-9a-f]+)/0xcffff lookup ", iface, NULL); @@ -346,7 +347,7 @@ static int get_route_mtu(const char *endpoint) DEFINE_CMD(c_route); DEFINE_CMD(c_dev); regmatch_t matches[2]; - regex_t regex_mtu, regex_dev; + _cleanup_regfree_ regex_t regex_mtu = { 0 }, regex_dev = { 0 }; char *route, *mtu, *dev; xregcomp(®ex_mtu, "mtu ([0-9]+)", REG_EXTENDED); @@ -380,7 +381,7 @@ static int get_route_mtu(const char *endpoint) static void set_mtu(const char *iface, unsigned int mtu) { DEFINE_CMD(c_endpoints); - regex_t regex_endpoint; + _cleanup_regfree_ regex_t regex_endpoint = { 0 }; regmatch_t matches[2]; int endpoint_mtu, next_mtu; @@ -466,7 +467,7 @@ set_back_down: static void maybe_unblock_ipv6(const char *iface) { regmatch_t matches[2]; - regex_t reg; + _cleanup_regfree_ regex_t reg = { 0 }; _cleanup_free_ char *regex = concat("^-A (.* --comment \"wireguard rule ", iface, "\"[^\n]*)\n*$", NULL); DEFINE_CMD(c); @@ -605,7 +606,7 @@ static void parse_options(char **iface, char **config, unsigned int *mtu, char * _cleanup_free_ char *line = NULL; _cleanup_free_ char *filename = NULL; _cleanup_free_ char *paths = strdup(WG_CONFIG_SEARCH_PATHS); - regex_t regex_iface, regex_conf; + _cleanup_regfree_ regex_t regex_iface = { 0 }, regex_conf = { 0 }; regmatch_t matches[2]; struct stat sbuf; size_t n = 0; |