diff --git a/src/config/PartitionConfig.cxx b/src/config/PartitionConfig.cxx index d3f0182ff..5a275cdc2 100644 --- a/src/config/PartitionConfig.cxx +++ b/src/config/PartitionConfig.cxx @@ -10,4 +10,11 @@ PartitionConfig::PartitionConfig(const ConfigData &config) queue.max_length = config.GetPositive(ConfigOption::MAX_PLAYLIST_LENGTH, QueueConfig::DEFAULT_MAX_LENGTH); + + if (queue.max_length > QueueConfig::MAX_MAX_LENGTH) + /* silently clip max_playlist_length to a resonable + limit to avoid out-of-memory during startup (or + worse, an integer overflow because the allocation + size is larger than SIZE_MAX) */ + queue.max_length = QueueConfig::MAX_MAX_LENGTH; } diff --git a/src/config/QueueConfig.hxx b/src/config/QueueConfig.hxx index 8d9183613..8766aa525 100644 --- a/src/config/QueueConfig.hxx +++ b/src/config/QueueConfig.hxx @@ -5,6 +5,7 @@ struct QueueConfig { static constexpr unsigned DEFAULT_MAX_LENGTH = 16 * 1024; + static constexpr unsigned MAX_MAX_LENGTH = 16 * 1024 * 1024; unsigned max_length = DEFAULT_MAX_LENGTH; };