Skip to content

Commit

Permalink
address coverity issues (#843)
Browse files Browse the repository at this point in the history
  • Loading branch information
anonrig authored Jan 17, 2025
1 parent 0394a7c commit 7dc872b
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 11 deletions.
7 changes: 1 addition & 6 deletions include/ada/url_components-inl.h
Original file line number Diff line number Diff line change
Expand Up @@ -24,15 +24,10 @@ namespace ada {
* `--------------------------------------------- protocol_end
*/
// These conditions can be made more strict.
uint32_t index = 0;

if (protocol_end == url_components::omitted) {
return false;
}
if (protocol_end < index) {
return false;
}
index = protocol_end;
uint32_t index = protocol_end;

if (username_end == url_components::omitted) {
return false;
Expand Down
10 changes: 5 additions & 5 deletions src/url.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -716,7 +716,7 @@ bool url::set_host_or_hostname(const std::string_view input) {

bool succeeded = parse_host(host_view);
if (!succeeded) {
host = previous_host;
host = std::move(previous_host);
update_base_port(previous_port);
}
return succeeded;
Expand All @@ -733,13 +733,13 @@ bool url::set_host_or_hostname(const std::string_view input) {
} else {
// Let host be the result of host parsing buffer with url is not special.
if (!parse_host(new_host)) {
host = previous_host;
host = std::move(previous_host);
update_base_port(previous_port);
return false;
}

// If host is "localhost", then set host to the empty string.
if (host.has_value() && host.value() == "localhost") {
if (host == "localhost") {
host = "";
}
}
Expand Down Expand Up @@ -794,7 +794,7 @@ bool url::set_port(const std::string_view input) {
if (is_valid) {
return true;
}
port = previous_port;
port = std::move(previous_port);
is_valid = true;
return false;
}
Expand Down Expand Up @@ -835,7 +835,7 @@ bool url::set_pathname(const std::string_view input) {
if (has_opaque_path) {
return false;
}
path = "";
path.clear();
parse_path(input);
return true;
}
Expand Down

0 comments on commit 7dc872b

Please sign in to comment.