Skip to content

Commit

Permalink
src: free memory first on URLHost::SetOpaque & URLHost::SetDomain call
Browse files Browse the repository at this point in the history
  • Loading branch information
prog1dev committed Jan 23, 2018
1 parent bd831b4 commit 4a2adb0
Showing 1 changed file with 2 additions and 0 deletions.
2 changes: 2 additions & 0 deletions src/node_url.cc
Original file line number Diff line number Diff line change
Expand Up @@ -110,11 +110,13 @@ class URLHost {
// These helpers are the easiest solution but we might want to consider
// just not forcing strings into an union.
inline void SetOpaque(std::string&& string) {
Reset();
type_ = HostType::H_OPAQUE;
new(&value_.opaque) std::string(std::move(string));
}

inline void SetDomain(std::string&& string) {
Reset();
type_ = HostType::H_DOMAIN;
new(&value_.domain) std::string(std::move(string));
}
Expand Down

0 comments on commit 4a2adb0

Please sign in to comment.