Skip to content

Commit

Permalink
Fix a memory leak of 104 bytes per hostname resolved.
Browse files Browse the repository at this point in the history
  • Loading branch information
bonsaiviking committed Jun 21, 2019
1 parent ace7fbd commit cb418ab
Showing 1 changed file with 6 additions and 1 deletion.
7 changes: 6 additions & 1 deletion TargetGroup.cc
Original file line number Diff line number Diff line change
Expand Up @@ -861,7 +861,12 @@ int TargetGroup::get_next_host(struct sockaddr_storage *ss, size_t *sslen) {
limit it to exactly one address). */
NetBlock *netblock_resolved = this->netblock->resolve();
if (netblock_resolved != NULL) {
this->netblock = netblock_resolved;
/* resolve may return the original netblock if it's not a type that needs
* to be resolved. Don't delete it! */
if (netblock_resolved != this->netblock) {
delete this->netblock;
this->netblock = netblock_resolved;
}
}
else {
error("Failed to resolve \"%s\".", this->netblock->hostname.c_str());
Expand Down

0 comments on commit cb418ab

Please sign in to comment.