diff --git a/src/zip.cpp b/src/zip.cpp index e4765d6..28be71f 100644 --- a/src/zip.cpp +++ b/src/zip.cpp @@ -27,6 +27,7 @@ #include #include #include +#include #include #include #include @@ -45,7 +46,18 @@ std::vector list(const fs::path &filepath) std::vector toc; while (archive_read_next_header(zipfile, &entry) == ARCHIVE_OK) { - toc.emplace_back(archive_entry_pathname_utf8(entry)); + const auto *in_epub_filepath{archive_entry_pathname_utf8(entry)}; + if (in_epub_filepath == nullptr) + { // If the encoding is broken, we skip the file. + std::cerr << translate("WARNING: ") + << format(translate("{0:s} is damaged. " + "Skipping rest of file.\n") + .str() + .data(), + filepath); + break; + } + toc.emplace_back(in_epub_filepath); archive_read_data_skip(zipfile); }