config/PartitionConfig: clip the max_playlist_length setting
Closes https://github.com/MusicPlayerDaemon/MPD/issues/1932
This commit is contained in:
parent
41a1e98cb9
commit
08a00ee21b
@ -10,4 +10,11 @@ PartitionConfig::PartitionConfig(const ConfigData &config)
|
|||||||
queue.max_length =
|
queue.max_length =
|
||||||
config.GetPositive(ConfigOption::MAX_PLAYLIST_LENGTH,
|
config.GetPositive(ConfigOption::MAX_PLAYLIST_LENGTH,
|
||||||
QueueConfig::DEFAULT_MAX_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;
|
||||||
}
|
}
|
||||||
|
@ -5,6 +5,7 @@
|
|||||||
|
|
||||||
struct QueueConfig {
|
struct QueueConfig {
|
||||||
static constexpr unsigned DEFAULT_MAX_LENGTH = 16 * 1024;
|
static constexpr unsigned DEFAULT_MAX_LENGTH = 16 * 1024;
|
||||||
|
static constexpr unsigned MAX_MAX_LENGTH = 16 * 1024 * 1024;
|
||||||
|
|
||||||
unsigned max_length = DEFAULT_MAX_LENGTH;
|
unsigned max_length = DEFAULT_MAX_LENGTH;
|
||||||
};
|
};
|
||||||
|
Loading…
Reference in New Issue
Block a user