diff options
author | Lasse Collin <lasse.collin@tukaani.org> | 2011-05-27 22:09:49 +0300 |
---|---|---|
committer | Lasse Collin <lasse.collin@tukaani.org> | 2011-05-28 09:44:07 +0300 |
commit | 844f84fcad9670c543550edf7c7e42630c8f7715 (patch) | |
tree | dfbf2c1923d588f28d66080d90fc4ac365f15f33 /src/liblzma/common/index.c | |
parent | Build: Set GZIP_ENV=-9n in top-level Makefile.am. (diff) | |
download | xz-844f84fcad9670c543550edf7c7e42630c8f7715.tar.xz |
liblzma: Handle allocation failures correctly in lzma_index_init().
Thanks to Jim Meyering.
Diffstat (limited to 'src/liblzma/common/index.c')
-rw-r--r-- | src/liblzma/common/index.c | 7 |
1 files changed, 5 insertions, 2 deletions
diff --git a/src/liblzma/common/index.c b/src/liblzma/common/index.c index ddb9d364..9af4bc19 100644 --- a/src/liblzma/common/index.c +++ b/src/liblzma/common/index.c @@ -398,10 +398,13 @@ extern LZMA_API(lzma_index *) lzma_index_init(lzma_allocator *allocator) { lzma_index *i = index_init_plain(allocator); + if (i == NULL) + return NULL; + index_stream *s = index_stream_init(0, 0, 1, 0, allocator); - if (i == NULL || s == NULL) { - index_stream_end(s, allocator); + if (s == NULL) { lzma_free(i, allocator); + return NULL; } index_tree_append(&i->streams, &s->node); |