Skip to content

Commit 6b6865c

Browse files
committed
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.
1 parent 2963960 commit 6b6865c

File tree

1 file changed

+2
-2
lines changed

1 file changed

+2
-2
lines changed

src/https_client.c

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -451,7 +451,7 @@ static int https_fetch_ctx_process_response(https_client_t *client,
451451
res = curl_easy_getinfo(ctx->curl, CURLINFO_EFFECTIVE_URL, &str_resp);
452452
if (res != CURLE_OK) {
453453
ELOG_REQ("CURLINFO_EFFECTIVE_URL: %s", curl_easy_strerror(res));
454-
} else {
454+
} else if (str_resp != NULL) {
455455
DLOG_REQ("CURLINFO_EFFECTIVE_URL: %s", str_resp);
456456
}
457457

@@ -465,7 +465,7 @@ static int https_fetch_ctx_process_response(https_client_t *client,
465465
res = curl_easy_getinfo(ctx->curl, CURLINFO_SCHEME, &str_resp);
466466
if (res != CURLE_OK) {
467467
ELOG_REQ("CURLINFO_SCHEME: %s", curl_easy_strerror(res));
468-
} else if (strcasecmp(str_resp, "https") != 0) {
468+
} else if (str_resp != NULL && strcasecmp(str_resp, "https") != 0) {
469469
DLOG_REQ("CURLINFO_SCHEME: %s", str_resp);
470470
}
471471

0 commit comments

Comments
 (0)