From c428f6aece6447b9a32bd6430f80a4b22e51663a Mon Sep 17 00:00:00 2001 From: Martin Hurton Date: Tue, 27 Mar 2012 06:16:33 +0200 Subject: [PATCH] tcp_address: check address length before manipulating it --- src/tcp_address.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/tcp_address.cpp b/src/tcp_address.cpp index d67392e3..46a2e36d 100644 --- a/src/tcp_address.cpp +++ b/src/tcp_address.cpp @@ -386,7 +386,7 @@ int zmq::tcp_address_t::resolve (const char *name_, bool local_, bool ipv4only_) std::string port_str (delimiter + 1); // Remove square brackets around the address, if any. - if (!addr_str.empty () && addr_str [0] == '[' && + if (addr_str.size () >= 2 && addr_str [0] == '[' && addr_str [addr_str.size () - 1] == ']') addr_str = addr_str.substr (1, addr_str.size () - 2);