From a57c895115f3894611560046ca919e770643662d Mon Sep 17 00:00:00 2001 From: Alexander Udovichenko Date: Thu, 20 Mar 2025 00:01:35 +0300 Subject: [PATCH] [mod_httpapi] Fix possible segfault when HEAD request fails --- src/mod/applications/mod_httapi/mod_httapi.c | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/src/mod/applications/mod_httapi/mod_httapi.c b/src/mod/applications/mod_httapi/mod_httapi.c index 1254a6f93c..62cc55eeb9 100644 --- a/src/mod/applications/mod_httapi/mod_httapi.c +++ b/src/mod/applications/mod_httapi/mod_httapi.c @@ -2676,7 +2676,13 @@ static switch_status_t fetch_cache_data(http_file_context_t *context, const char if (err_msg) { *err_msg = "response code != 200"; } - switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_WARNING, "caching: url:%s to %s failed with HTTP response code %d\n", url, save_path, (int)code); + + if (save_path) { + switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_WARNING, "caching: url:%s to %s failed with HTTP response code %d\n", url, save_path, (int)code); + } else { + switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_WARNING, "head: url:%s failed with HTTP response code %d\n", url, (int)code); + } + status = SWITCH_STATUS_FALSE; break; }