Skip to content

Commit

Permalink
Merge pull request shadowsocks#98 from beeender/leak-fix
Browse files Browse the repository at this point in the history
Small leak fix
  • Loading branch information
clowwindy committed Jun 16, 2015
2 parents a423ccb + b7ec4e8 commit 43a3a64
Showing 1 changed file with 9 additions and 3 deletions.
12 changes: 9 additions & 3 deletions src/chinadns.c
Original file line number Diff line number Diff line change
Expand Up @@ -238,9 +238,6 @@ static int setnonblock(int sock) {

static int parse_args(int argc, char **argv) {
int ch;
dns_servers = strdup(default_dns_servers);
listen_addr = strdup(default_listen_addr);
listen_port = strdup(default_listen_port);
while ((ch = getopt(argc, argv, "hb:p:s:l:c:y:dmvV")) != -1) {
switch (ch) {
case 'h':
Expand Down Expand Up @@ -281,6 +278,15 @@ static int parse_args(int argc, char **argv) {
exit(1);
}
}
if (dns_servers == NULL) {
dns_servers = strdup(default_dns_servers);
}
if (listen_addr == NULL) {
listen_addr = strdup(default_listen_addr);
}
if (listen_port == NULL) {
listen_port = strdup(default_listen_port);
}
argc -= optind;
argv += optind;
return 0;
Expand Down

0 comments on commit 43a3a64

Please sign in to comment.