liblzma: Check the return value of lzma_index_append() in threaded encoder.
If lzma_index_append() failed (most likely memory allocation failure) it could have gone unnoticed and the resulting .xz file would have an incorrect Index. Decompressing such a file would produce the correct uncompressed data but then an error would occur when verifying the Index field.
This commit is contained in:
parent
5313ad66b4
commit
4f78f5fcf6
|
@ -732,6 +732,10 @@ stream_encode_mt(void *coder_ptr, const lzma_allocator *allocator,
|
||||||
ret = lzma_index_append(coder->index,
|
ret = lzma_index_append(coder->index,
|
||||||
allocator, unpadded_size,
|
allocator, unpadded_size,
|
||||||
uncompressed_size);
|
uncompressed_size);
|
||||||
|
if (ret != LZMA_OK) {
|
||||||
|
threads_stop(coder, false);
|
||||||
|
return ret;
|
||||||
|
}
|
||||||
|
|
||||||
// If we didn't fill the output buffer yet,
|
// If we didn't fill the output buffer yet,
|
||||||
// try to read more data. Maybe the next
|
// try to read more data. Maybe the next
|
||||||
|
@ -741,8 +745,7 @@ stream_encode_mt(void *coder_ptr, const lzma_allocator *allocator,
|
||||||
}
|
}
|
||||||
|
|
||||||
if (ret != LZMA_OK) {
|
if (ret != LZMA_OK) {
|
||||||
// coder->thread_error was set or
|
// coder->thread_error was set.
|
||||||
// lzma_index_append() failed.
|
|
||||||
threads_stop(coder, false);
|
threads_stop(coder, false);
|
||||||
return ret;
|
return ret;
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue