summaryrefslogtreecommitdiff
path: root/src/lib/net
diff options
context:
space:
mode:
Diffstat (limited to 'src/lib/net')
-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) {