Skip to content

Commit

Permalink
Fixed some memory leaks (#20)
Browse files Browse the repository at this point in the history
  • Loading branch information
ysyrota authored Aug 22, 2024
1 parent f12f640 commit c46ef29
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 5 deletions.
1 change: 1 addition & 0 deletions duo.c
Original file line number Diff line number Diff line change
Expand Up @@ -658,6 +658,7 @@ duo_auth_free(struct duo_auth *auth)
json_value_free(prv->json);
if (prv->body)
free(prv->body);
free(prv);
}
free(auth);
}
Expand Down
15 changes: 10 additions & 5 deletions https.c
Original file line number Diff line number Diff line change
Expand Up @@ -544,7 +544,6 @@ HTTPScode
https_send(struct https_request *req, const char *method, const char *uri,
const char *qs, const char *hdrs)
{
char *p;
int n, qsbody;

req->done = 0;
Expand All @@ -571,10 +570,16 @@ https_send(struct https_request *req, const char *method, const char *uri,
ctx->useragent);

/* Add headers */
if (hdrs != NULL && (p = strdup(hdrs)) != NULL) {
BIO_printf(req->cbio, "%s\r\n", strtok(p, "\r\n"));
while ((p = strtok(NULL, "\r\n")) != NULL && *p)
BIO_printf(req->cbio, "%s\r\n", p);
if (hdrs != NULL) {
char *hdrs_dup = strdup(hdrs);
if (hdrs_dup != NULL) {
char *p = strtok(hdrs_dup, "\r\n");
while (p) {
BIO_printf(req->cbio, "%s\r\n", p);
p = strtok(NULL, "\r\n");
}
free(hdrs_dup);
}
}
/* Finish request */
if (qs != NULL && qsbody) {
Expand Down

0 comments on commit c46ef29

Please sign in to comment.