aboutsummaryrefslogtreecommitdiff
path: root/src/liblzma/common/index.c
diff options
context:
space:
mode:
authorLasse Collin <lasse.collin@tukaani.org>2015-10-12 20:45:15 +0300
committerLasse Collin <lasse.collin@tukaani.org>2015-10-12 20:45:15 +0300
commit21515d79d778b8730a434f151b07202d52a04611 (patch)
tree9e06ecb13ced9bea05ffdbdb9496beadda93e44f /src/liblzma/common/index.c
parentliblzma: Add a note to index.c for those using static analyzers. (diff)
downloadxz-21515d79d778b8730a434f151b07202d52a04611.tar.xz
liblzma: Fix lzma_index_dup() for empty Streams.
Stream Flags and Stream Padding weren't copied from empty Streams.
Diffstat (limited to '')
-rw-r--r--src/liblzma/common/index.c11
1 files changed, 6 insertions, 5 deletions
diff --git a/src/liblzma/common/index.c b/src/liblzma/common/index.c
index bc1ef292..26e4e519 100644
--- a/src/liblzma/common/index.c
+++ b/src/liblzma/common/index.c
@@ -872,11 +872,8 @@ index_dup_stream(const index_stream *src, const lzma_allocator *allocator)
index_stream *dest = index_stream_init(src->node.compressed_base,
src->node.uncompressed_base, src->number,
src->block_number_base, allocator);
-
- // Return immediately if allocation failed or if there are
- // no groups to duplicate.
- if (dest == NULL || src->groups.leftmost == NULL)
- return dest;
+ if (dest == NULL)
+ return NULL;
// Copy the overall information.
dest->record_count = src->record_count;
@@ -884,6 +881,10 @@ index_dup_stream(const index_stream *src, const lzma_allocator *allocator)
dest->stream_flags = src->stream_flags;
dest->stream_padding = src->stream_padding;
+ // Return if there are no groups to duplicate.
+ if (src->groups.leftmost == NULL)
+ return dest;
+
// Allocate memory for the Records. We put all the Records into
// a single group. It's simplest and also tends to make
// lzma_index_locate() a little bit faster with very big Indexes.