mirror of
https://git.tukaani.org/xz.git
synced 2024-04-04 12:36:23 +02:00
Validate the filter chain before checking filter-specific
memory usage.
This commit is contained in:
parent
c596fda40b
commit
ccd57afa09
1 changed files with 10 additions and 4 deletions
|
@ -227,8 +227,11 @@ lzma_memusage_coder(lzma_filter_find coder_find,
|
||||||
const lzma_filter *filters)
|
const lzma_filter *filters)
|
||||||
{
|
{
|
||||||
// The chain has to have at least one filter.
|
// The chain has to have at least one filter.
|
||||||
if (filters[0].id == LZMA_VLI_UNKNOWN)
|
{
|
||||||
return UINT64_MAX;
|
size_t tmp;
|
||||||
|
if (validate_chain(filters, &tmp) != LZMA_OK)
|
||||||
|
return UINT64_MAX;
|
||||||
|
}
|
||||||
|
|
||||||
uint64_t total = 0;
|
uint64_t total = 0;
|
||||||
size_t i = 0;
|
size_t i = 0;
|
||||||
|
@ -241,8 +244,11 @@ lzma_memusage_coder(lzma_filter_find coder_find,
|
||||||
|
|
||||||
if (fc->memusage == NULL) {
|
if (fc->memusage == NULL) {
|
||||||
// This filter doesn't have a function to calculate
|
// This filter doesn't have a function to calculate
|
||||||
// the memory usage. Such filters need only little
|
// the memory usage and validate the options. Such
|
||||||
// memory, so we use 1 KiB as a good estimate.
|
// filters need only little memory, so we use 1 KiB
|
||||||
|
// as a good estimate. They also accept all possible
|
||||||
|
// options, so there's no need to worry about lack
|
||||||
|
// of validation.
|
||||||
total += 1024;
|
total += 1024;
|
||||||
} else {
|
} else {
|
||||||
// Call the filter-specific memory usage calculation
|
// Call the filter-specific memory usage calculation
|
||||||
|
|
Loading…
Reference in a new issue