Skip to content

Commit

Permalink
Fix leaks and warnings reported by valgrind
Browse files Browse the repository at this point in the history
  • Loading branch information
sonertari committed May 6, 2020
1 parent baf3859 commit 9bac829
Show file tree
Hide file tree
Showing 3 changed files with 13 additions and 5 deletions.
2 changes: 2 additions & 0 deletions main.c
Original file line number Diff line number Diff line change
Expand Up @@ -911,6 +911,8 @@ main(int argc, char *argv[])
out_parent:
opts_free(opts);
ssl_fini();
if (natengine)
free(natengine);
return rv;
}

Expand Down
11 changes: 7 additions & 4 deletions opts.c
Original file line number Diff line number Diff line change
Expand Up @@ -162,6 +162,9 @@ opts_free(opts_t *opts)
if (opts->connectlog) {
free(opts->connectlog);
}
if (opts->conffile) {
free(opts->conffile);
}
if (opts->contentlog) {
free(opts->contentlog);
}
Expand Down Expand Up @@ -1644,9 +1647,8 @@ opts_set_option(opts_t *opts, const char *argv0, const char *optarg,
retval = set_option(opts, argv0, name, value, natengine, 0);
}

if (line) {
if (line)
free(line);
}
return retval;
}

Expand Down Expand Up @@ -1694,13 +1696,14 @@ load_conffile(opts_t *opts, const char *argv0, char **natengine)
if (retval == -1) {
goto leave;
}
free(line);
line = NULL;
}

leave:
fclose(f);
if (line) {
if (line)
free(line);
}
return retval;
}

Expand Down
5 changes: 4 additions & 1 deletion pxyconn.c
Original file line number Diff line number Diff line change
Expand Up @@ -1301,7 +1301,10 @@ bufferevent_free_and_close_fd(struct bufferevent *bev, pxy_conn_ctx_t *ctx)
}
SSL_free(ssl);
}
evutil_closesocket(fd);
/* bufferevent_getfd() returns -1 if no file descriptor is associated
* with the bufferevent */
if (fd >= 0)
evutil_closesocket(fd);
}

/*
Expand Down

0 comments on commit 9bac829

Please sign in to comment.