diff options
author | Eduardo Chappa <chappa@washington.edu> | 2022-06-10 19:42:36 -0600 |
---|---|---|
committer | Eduardo Chappa <chappa@washington.edu> | 2022-06-10 19:42:36 -0600 |
commit | 21813be5a29ac9a2c6e9075383c528b4b52d6c5f (patch) | |
tree | 2977a4482ce56e8c9458686f6885d86ffda8fe22 | |
parent | 1f26808faba44fe9140d19cf93d7b8560513e5ec (diff) | |
download | alpine-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.
-rw-r--r-- | alpine/xoauth2conf.c | 2 | ||||
-rw-r--r-- | imap/src/c-client/http.c | 11 | ||||
-rw-r--r-- | imap/src/c-client/oauth2_aux.c | 12 | ||||
-rw-r--r-- | pith/pine.hlp | 2 | ||||
-rw-r--r-- | pith/smime.c | 1 |
5 files changed, 21 insertions, 7 deletions
diff --git a/alpine/xoauth2conf.c b/alpine/xoauth2conf.c index eca97e92..5bf3e185 100644 --- a/alpine/xoauth2conf.c +++ b/alpine/xoauth2conf.c @@ -347,11 +347,13 @@ xoauth2_configured_servers(void) for(j = 0; rv[j] && !same_xoauth2_info(*cv[i], *rv[j]); j++); if(!rv[j]) rv[total++] = copy_xoauth2_info(cv[i]); } + free_xoauth2_info_list(&cv); for(i = 0; muv && muv[i]; i++){ for(j = 0; rv[j] && !same_xoauth2_info(*muv[i], *rv[j]); j++); if(!rv[j]) rv[total++] = copy_xoauth2_info(muv[i]); } + free_xoauth2_info_list(&muv); } return rv; } 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); } diff --git a/pith/pine.hlp b/pith/pine.hlp index 05c6eba2..58c6da54 100644 --- a/pith/pine.hlp +++ b/pith/pine.hlp @@ -147,7 +147,7 @@ with help text for the config screen and the composer that didn't have any reasonable place to be called from. Dummy change to get revision in pine.hlp ============= h_revision ================= -Alpine Commit 651 2022-06-05 13:33:49 +Alpine Commit 652 2022-06-10 19:41:14 ============= h_news ================= <HTML> <HEAD> diff --git a/pith/smime.c b/pith/smime.c index 9b5e9c96..e330d1c9 100644 --- a/pith/smime.c +++ b/pith/smime.c @@ -3266,6 +3266,7 @@ decrypt_file(char *fp, int *rv, PERSONAL_CERT *pc) long unsigned int len; void *ret; + if(rv) *rv = -1; /* assume failure */ if(pc == NULL || (text = read_file(fp, 0)) == NULL || *text == '\0') return NULL; |