diary

Text-based journaling program
git clone https://git.in0rdr.ch/diary.git
Log | Files | Refs | README | LICENSE

commit 5a08084095e83538b916f3bb1ebde274e117b822
parent fcde060fbbcbcc2f0c325a1b6fe370882153ea4d
Author: Andreas Gruhler <agruhl@gmx.ch>
Date:   Sun, 23 Jan 2022 23:16:07 +0100

fix def lost block in caldav_req on curl error

Diffstat:
Msrc/caldav.c | 10+++++-----
1 file changed, 5 insertions(+), 5 deletions(-)

diff --git a/src/caldav.c b/src/caldav.c @@ -101,7 +101,7 @@ char* read_tokenfile() { token_buf[token_bytes] = '\0'; char* new_access_token = extract_json_value(token_buf, "access_token", true); - fprintf(stderr, "New access token: %s\n", new_access_token); + fprintf(stderr, "Info - New access token: %s\n", new_access_token); if (new_access_token != NULL) { strncpy(access_token, new_access_token, 200); free(new_access_token); @@ -442,6 +442,7 @@ char* caldav_req(struct tm* date, char* url, char* http_method, char* postfields if (res != CURLE_OK) { fprintf(stderr, "Error - curl_easy_perform() failed: %s\n", curl_easy_strerror(res)); + free(caldav_resp.memory); return NULL; } } @@ -627,7 +628,6 @@ int caldav_sync(struct tm* date, char* user_principal = caldav_req(date, GOOGLE_CALDAV_URI, "PROPFIND", principal_postfields, 0); if (user_principal == NULL) { - free(user_principal); fprintf(stderr, "Info - Unable to fetch principal, refreshing API token.\n"); // The principal could not be fetched, // get new acess token with refresh token @@ -765,7 +765,7 @@ int caldav_sync(struct tm* date, // purge any existing daily calendar entries on the remote side char event_uri[300]; sprintf(event_uri, "%s%s%s.ics", GOOGLE_API_URI, calendar_href, remote_uid); - fprintf(stderr, "DELETE Url: %s\n", event_uri); + fprintf(stderr, "Info - DELETE Url: %s\n", event_uri); char* response = caldav_req(date, event_uri, "DELETE", NULL, 0); free(response); } @@ -838,11 +838,11 @@ int caldav_sync(struct tm* date, echo(); curs_set(0); free(rmt_desc); - free(remote_uid); - free(home_set); // home_set was required for sprintfing calendar_href to event_uri } // free memory allocated to store curl response free(event); + free(remote_uid); + free(home_set); // home_set was required for sprintfing calendar_href to event_uri return conf_ch; } \ No newline at end of file