From 6b6865c206a5e95a99bfb041301bc12b8ad564c8 Mon Sep 17 00:00:00 2001 From: "re:fi.64" Date: Fri, 6 Jun 2025 20:17:02 -0500 Subject: [PATCH] Fix missing null checks when debug logging request information On some types of errors (e.g. early connection failures), `CURLINFO_EFFECTIVE_URL` and `CURLINFO_SCHEME` might not ever get set, resulting in a segfault when trying to acces their contents. --- src/https_client.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/https_client.c b/src/https_client.c index 7b21227..f633781 100644 --- a/src/https_client.c +++ b/src/https_client.c @@ -451,7 +451,7 @@ static int https_fetch_ctx_process_response(https_client_t *client, res = curl_easy_getinfo(ctx->curl, CURLINFO_EFFECTIVE_URL, &str_resp); if (res != CURLE_OK) { ELOG_REQ("CURLINFO_EFFECTIVE_URL: %s", curl_easy_strerror(res)); - } else { + } else if (str_resp != NULL) { DLOG_REQ("CURLINFO_EFFECTIVE_URL: %s", str_resp); } @@ -465,7 +465,7 @@ static int https_fetch_ctx_process_response(https_client_t *client, res = curl_easy_getinfo(ctx->curl, CURLINFO_SCHEME, &str_resp); if (res != CURLE_OK) { ELOG_REQ("CURLINFO_SCHEME: %s", curl_easy_strerror(res)); - } else if (strcasecmp(str_resp, "https") != 0) { + } else if (str_resp != NULL && strcasecmp(str_resp, "https") != 0) { DLOG_REQ("CURLINFO_SCHEME: %s", str_resp); }