archive/List: disallow passing suffix==nullptr to archive_plugin_from_suffix()

This commit is contained in:
Max Kellermann 2019-05-31 19:05:26 +02:00
parent 12e75a523a
commit 0e8ca44968
2 changed files with 4 additions and 2 deletions

View File

@ -26,6 +26,7 @@
#include "plugins/ZzipArchivePlugin.hxx" #include "plugins/ZzipArchivePlugin.hxx"
#include "util/Macros.hxx" #include "util/Macros.hxx"
#include <assert.h>
#include <string.h> #include <string.h>
const ArchivePlugin *const archive_plugins[] = { const ArchivePlugin *const archive_plugins[] = {
@ -51,8 +52,7 @@ static bool archive_plugins_enabled[ARRAY_SIZE(archive_plugins) - 1];
const ArchivePlugin * const ArchivePlugin *
archive_plugin_from_suffix(const char *suffix) noexcept archive_plugin_from_suffix(const char *suffix) noexcept
{ {
if (suffix == nullptr) assert(suffix != nullptr);
return nullptr;
archive_plugins_for_each_enabled(plugin) archive_plugins_for_each_enabled(plugin)
if (plugin->suffixes != nullptr && if (plugin->suffixes != nullptr &&

View File

@ -58,6 +58,8 @@ OpenArchiveInputStream(Path path, Mutex &mutex)
} }
const char *suffix = Path::FromFS(archive).GetSuffix(); const char *suffix = Path::FromFS(archive).GetSuffix();
if (suffix == nullptr)
return nullptr;
//check which archive plugin to use (by ext) //check which archive plugin to use (by ext)
arplug = archive_plugin_from_suffix(suffix); arplug = archive_plugin_from_suffix(suffix);