Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(1046)

Unified Diff: src/liblzma/common/stream_buffer_encoder.c

Issue 7109015: Update XZ Utils to 5.0.3 (in deps) (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/deps/third_party/xz/
Patch Set: Created 9 years, 7 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
« no previous file with comments | « src/liblzma/common/index_encoder.c ('k') | src/liblzma/common/stream_encoder.c » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: src/liblzma/common/stream_buffer_encoder.c
===================================================================
--- src/liblzma/common/stream_buffer_encoder.c (revision 50504)
+++ src/liblzma/common/stream_buffer_encoder.c (working copy)
@@ -51,6 +51,9 @@
|| out_pos_ptr == NULL || *out_pos_ptr > out_size)
return LZMA_PROG_ERROR;
+ if (!lzma_check_is_supported(check))
+ return LZMA_UNSUPPORTED_CHECK;
+
// Note for the paranoids: Index encoder prevents the Stream from
// getting too big and still being accepted with LZMA_OK, and Block
// encoder catches if the input is too big. So we don't need to
@@ -81,27 +84,33 @@
out_pos += LZMA_STREAM_HEADER_SIZE;
- // Block
+ // Encode a Block but only if there is at least one byte of input.
lzma_block block = {
.version = 0,
.check = check,
.filters = filters,
};
- return_if_error(lzma_block_buffer_encode(&block, allocator,
- in, in_size, out, &out_pos, out_size));
+ if (in_size > 0)
+ return_if_error(lzma_block_buffer_encode(&block, allocator,
+ in, in_size, out, &out_pos, out_size));
// Index
{
- // Create an Index with one Record.
+ // Create an Index. It will have one Record if there was
+ // at least one byte of input to encode. Otherwise the
+ // Index will be empty.
lzma_index *i = lzma_index_init(allocator);
if (i == NULL)
return LZMA_MEM_ERROR;
- lzma_ret ret = lzma_index_append(i, allocator,
- lzma_block_unpadded_size(&block),
- block.uncompressed_size);
+ lzma_ret ret = LZMA_OK;
+ if (in_size > 0)
+ ret = lzma_index_append(i, allocator,
+ lzma_block_unpadded_size(&block),
+ block.uncompressed_size);
+
// If adding the Record was successful, encode the Index
// and get its size which will be stored into Stream Footer.
if (ret == LZMA_OK) {
« no previous file with comments | « src/liblzma/common/index_encoder.c ('k') | src/liblzma/common/stream_encoder.c » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698