Skip to content

Commit

Permalink
Destroy options if ares_save_options fails
Browse files Browse the repository at this point in the history
It's possible that, if ares_save_options failed, the opts structure
would contain some allocated memory. Calling ares_destroy_options in
this case is safe, because ares_save_options zeroes out the memory
initially.
  • Loading branch information
jhrozek committed Nov 6, 2014
1 parent a0b24be commit 4535783
Showing 1 changed file with 3 additions and 0 deletions.
3 changes: 3 additions & 0 deletions ares_init.c
Original file line number Diff line number Diff line change
Expand Up @@ -266,7 +266,10 @@ int ares_dup(ares_channel *dest, ares_channel src)
which is most of them */
rc = ares_save_options(src, &opts, &optmask);
if(rc)
{
ares_destroy_options(&opts);
return rc;
}

/* Then create the new channel with those options */
rc = ares_init_options(dest, &opts, optmask);
Expand Down

0 comments on commit 4535783

Please sign in to comment.