From 0e8ca44968607bb0e23ece0b789439fff3091e63 Mon Sep 17 00:00:00 2001 From: Max Kellermann Date: Fri, 31 May 2019 19:05:26 +0200 Subject: [PATCH] archive/List: disallow passing suffix==nullptr to archive_plugin_from_suffix() --- src/archive/ArchiveList.cxx | 4 ++-- src/input/plugins/ArchiveInputPlugin.cxx | 2 ++ 2 files changed, 4 insertions(+), 2 deletions(-) diff --git a/src/archive/ArchiveList.cxx b/src/archive/ArchiveList.cxx index f0506bdd4..41492f824 100644 --- a/src/archive/ArchiveList.cxx +++ b/src/archive/ArchiveList.cxx @@ -26,6 +26,7 @@ #include "plugins/ZzipArchivePlugin.hxx" #include "util/Macros.hxx" +#include #include const ArchivePlugin *const archive_plugins[] = { @@ -51,8 +52,7 @@ static bool archive_plugins_enabled[ARRAY_SIZE(archive_plugins) - 1]; const ArchivePlugin * archive_plugin_from_suffix(const char *suffix) noexcept { - if (suffix == nullptr) - return nullptr; + assert(suffix != nullptr); archive_plugins_for_each_enabled(plugin) if (plugin->suffixes != nullptr && diff --git a/src/input/plugins/ArchiveInputPlugin.cxx b/src/input/plugins/ArchiveInputPlugin.cxx index cd918ef37..e2d5450a2 100644 --- a/src/input/plugins/ArchiveInputPlugin.cxx +++ b/src/input/plugins/ArchiveInputPlugin.cxx @@ -58,6 +58,8 @@ OpenArchiveInputStream(Path path, Mutex &mutex) } const char *suffix = Path::FromFS(archive).GetSuffix(); + if (suffix == nullptr) + return nullptr; //check which archive plugin to use (by ext) arplug = archive_plugin_from_suffix(suffix);