summaryrefslogtreecommitdiff
path: root/src/common/util.c
diff options
context:
space:
mode:
authorrl1987 <rl1987@sdf.lonestar.org>2018-02-12 21:08:17 +0100
committerNick Mathewson <nickm@torproject.org>2018-03-28 07:39:03 -0400
commit5986589b48de6addf99436df1feeea1362767acb (patch)
tree72df6f5c65c03af9eb399ae27ffc3624c8e5d6ba /src/common/util.c
parentb0ba4aa7e98af030e0e1be19a58ab7a6f00fa423 (diff)
downloadtor-5986589b48de6addf99436df1feeea1362767acb.tar.gz
tor-5986589b48de6addf99436df1feeea1362767acb.zip
Call strlen() once
Diffstat (limited to 'src/common/util.c')
-rw-r--r--src/common/util.c7
1 files changed, 4 insertions, 3 deletions
diff --git a/src/common/util.c b/src/common/util.c
index ea0ec3daee..d8891c6a53 100644
--- a/src/common/util.c
+++ b/src/common/util.c
@@ -1081,12 +1081,13 @@ string_is_valid_dest(const char *string)
{
char *tmp = NULL;
int retval;
+ size_t len = strlen(string);
tor_assert(string);
- tor_assert(strlen(string) > 0);
+ tor_assert(len > 0);
- if (string[0] == '[' && string[strlen(string) - 1] == ']')
- string = tmp = tor_strndup(string + 1, strlen(string) - 2);
+ if (string[0] == '[' && string[len - 1] == ']')
+ string = tmp = tor_strndup(string + 1, len - 2);
retval = string_is_valid_ipv4_address(string) ||
string_is_valid_ipv6_address(string) ||