Skip to content

Commit d997b02

Browse files
author
Igor Egorov
authored
Prevent access to uninitialized memory in Multiaddress (#259)
Signed-off-by: Igor Egorov <[email protected]>
1 parent 9e86ed8 commit d997b02

1 file changed

Lines changed: 6 additions & 0 deletions

File tree

src/multi/multiaddress.cpp

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -200,6 +200,9 @@ namespace libp2p::multi {
200200
}
201201

202202
std::list<Protocol> Multiaddress::getProtocols() const {
203+
if (stringified_address_.empty()) {
204+
return {};
205+
}
203206
std::string_view addr{stringified_address_};
204207
addr.remove_prefix(1);
205208

@@ -219,6 +222,9 @@ namespace libp2p::multi {
219222

220223
std::vector<std::pair<Protocol, std::string>>
221224
Multiaddress::getProtocolsWithValues() const {
225+
if (stringified_address_.empty()) {
226+
return {};
227+
}
222228
std::string_view addr{stringified_address_};
223229
addr.remove_prefix(1);
224230
if (addr.back() == '/') {

0 commit comments

Comments
 (0)