From 4c3c958ab136136c5a1b626410486bc9dd1c29be Mon Sep 17 00:00:00 2001 From: Tim Stack Date: Sat, 20 Apr 2024 06:45:38 -0700 Subject: [PATCH] [archive_manager] handle null error string --- src/archive_manager.cc | 20 ++++++++++---------- 1 file changed, 10 insertions(+), 10 deletions(-) diff --git a/src/archive_manager.cc b/src/archive_manager.cc index 3b7e8e67..0f33cba0 100644 --- a/src/archive_manager.cc +++ b/src/archive_manager.cc @@ -132,19 +132,19 @@ describe(const fs::path& filename) return Ok(describe_result{ai}); } - log_info("archive read header failed: %s -- %s", - filename.c_str(), - archive_error_string(arc)); - return Err(fmt::format(FMT_STRING("unable to read header: {} -- {}"), - filename, - archive_error_string(arc))); + const auto* errstr = archive_error_string(arc); + log_info( + "archive read header failed: %s -- %s", filename.c_str(), errstr); + return Err( + fmt::format(FMT_STRING("unable to read archive header: {} -- {}"), + filename, + errstr ? errstr : "not an archive")); } else { - log_info("archive open failed: %s -- %s", - filename.c_str(), - archive_error_string(arc)); + const auto* errstr = archive_error_string(arc); + log_info("archive open failed: %s -- %s", filename.c_str(), errstr); return Err(fmt::format(FMT_STRING("unable to open file: {} -- {}"), filename, - archive_error_string(arc))); + errstr ? errstr : "unknown")); } #endif