aboutsummaryrefslogtreecommitdiff
path: root/src/lib/net/address.c
diff options
context:
space:
mode:
authorrl1987 <rl1987@sdf.lonestar.org>2018-09-01 21:22:47 +0300
committerNick Mathewson <nickm@torproject.org>2018-10-30 09:05:11 -0400
commit1425549ca61cab8aa9476a25be0a31f726672bcc (patch)
treee06c6cb9aa77a37fc843e38836484b9fd79bce65 /src/lib/net/address.c
parent742cd1564993faefded2d33b6839428a1fe4412a (diff)
downloadtor-1425549ca61cab8aa9476a25be0a31f726672bcc.tar.gz
tor-1425549ca61cab8aa9476a25be0a31f726672bcc.zip
Code cleanups for tor_addr_parse()
Diffstat (limited to 'src/lib/net/address.c')
-rw-r--r--src/lib/net/address.c6
1 files changed, 3 insertions, 3 deletions
diff --git a/src/lib/net/address.c b/src/lib/net/address.c
index 17f4b1cf7a..a87d4a36a3 100644
--- a/src/lib/net/address.c
+++ b/src/lib/net/address.c
@@ -1189,13 +1189,13 @@ tor_addr_parse(tor_addr_t *addr, const char *src)
struct in6_addr in6_tmp;
int brackets_detected = 0;
+ tor_assert(addr && src);
+
size_t len = strlen(src);
- tor_assert(addr && src);
- if (src[0] == '[' && src[1] && src[len - 1] == ']') {
+ if (len && src[0] == '[' && src[len - 1] == ']') {
brackets_detected = 1;
src = tmp = tor_strndup(src+1, strlen(src)-2);
- len -= 2;
}
if (tor_inet_pton(AF_INET6, src, &in6_tmp) > 0) {