summaryrefslogtreecommitdiff
path: root/imap
diff options
context:
space:
mode:
authorEduardo Chappa <chappa@washington.edu>2022-06-10 19:42:36 -0600
committerEduardo Chappa <chappa@washington.edu>2022-06-10 19:42:36 -0600
commit21813be5a29ac9a2c6e9075383c528b4b52d6c5f (patch)
tree2977a4482ce56e8c9458686f6885d86ffda8fe22 /imap
parent1f26808faba44fe9140d19cf93d7b8560513e5ec (diff)
downloadalpine-21813be5a29ac9a2c6e9075383c528b4b52d6c5f.tar.xz
* Cleaning up some memory leaks reported by Valgrind. Memory leaks in the
handling of http headers will be handled through a different update.
Diffstat (limited to 'imap')
-rw-r--r--imap/src/c-client/http.c11
-rw-r--r--imap/src/c-client/oauth2_aux.c12
2 files changed, 17 insertions, 6 deletions
diff --git a/imap/src/c-client/http.c b/imap/src/c-client/http.c
index f1602621..bb0f34d4 100644
--- a/imap/src/c-client/http.c
+++ b/imap/src/c-client/http.c
@@ -87,6 +87,7 @@ typedef struct http_header_data_s {
/* helper functions */
HTTP_STATUS_S *http_status_line_get(unsigned char *);
void http_status_line_free(HTTP_STATUS_S **);
+void http_header_free(HTTP_HEADER_DATA_S **);
void buffer_add(unsigned char **, unsigned char *);
unsigned char *hex_escape_url_part(unsigned char *, unsigned char *);
unsigned char *encode_url_body_part(unsigned char *, unsigned char *);
@@ -990,11 +991,21 @@ http_get(HTTPSTREAM *stream, HTTP_PARAM_S **h)
}
void
+http_header_free(HTTP_HEADER_DATA_S **hdata)
+{
+ if(hdata == NULL || *hdata == NULL) return;
+
+ fs_give((void **) hdata);
+}
+
+void
http_close (HTTPSTREAM *stream)
{
if(stream){
if (stream->netstream) net_close (stream->netstream);
stream->netstream = NIL;
+ if(stream->status) http_status_line_free(&stream->status);
+ if(stream->header) http_header_free(&stream->header);
if (stream->url) fs_give ((void **) &stream->url);
if (stream->urlhost) fs_give ((void **) &stream->urlhost);
if (stream->urltail) fs_give ((void **) &stream->urltail);
diff --git a/imap/src/c-client/oauth2_aux.c b/imap/src/c-client/oauth2_aux.c
index 7c53f023..60e3b88d 100644
--- a/imap/src/c-client/oauth2_aux.c
+++ b/imap/src/c-client/oauth2_aux.c
@@ -46,8 +46,6 @@ char *xoauth2_server(char *, char *);
void oauth2_free_extra_values(OAUTH2_S oauth2)
{
- OA2_type i;
-
if(oauth2.param[OA2_Id].value) fs_give((void **) &oauth2.param[OA2_Id].value);
if(oauth2.param[OA2_Secret].value) fs_give((void **) &oauth2.param[OA2_Secret].value);
if(oauth2.param[OA2_Tenant].value) fs_give((void **) &oauth2.param[OA2_Tenant].value);
@@ -174,12 +172,11 @@ char *
xoauth2_server(char *server, char *tenant)
{
char *rv = NULL;
- char *s;
if (server == NULL) return NULL;
- s = cpystr(server);
if(tenant){
+ char *s = cpystr(server);
char *t = s, *u;
int i;
for(i = 0; t != NULL; i++){
@@ -198,6 +195,7 @@ xoauth2_server(char *server, char *tenant)
}
u = t;
}
+ fs_give((void **) &s);
}
else
rv = cpystr(server);
@@ -262,6 +260,7 @@ mm_login_oauth2_c_client_method (NETMBX *mb, char *user, char *method,
if(oauth2->param[OA2_Id].value == NULL
|| (oauth2->require_secret && oauth2->param[OA2_Secret].value == NULL)){
*tryanother = 1;
+ oauth2_free_extra_values(*oauth2);
mm_log("could not get client-id or client-secret required and empty.", (long) NIL);
return;
}
@@ -382,6 +381,7 @@ mm_login_oauth2_c_client_method (NETMBX *mb, char *user, char *method,
oauth2->param[OA2_Code].value = (*ogac)(url, method, oauth2, tryanother);
if(server) fs_give((void **) &server);
+ if(url) fs_give((void **) &url);
}
if(oauth2->param[OA2_Code].value){
@@ -560,9 +560,9 @@ free_xoauth2_info_list(XOAUTH2_INFO_S ***xp)
{
int i;
- if(xp == NULL || *xp == NULL || **xp) return;
+ if(xp == NULL || *xp == NULL || **xp == NULL) return;
for(i = 0; (*xp)[i] != NULL; i++) free_xoauth2_info(&(*xp)[i]);
- fs_give((void **) &xp);
+ fs_give((void **) xp);
}