mirror of
https://git.tukaani.org/xz.git
synced 2024-04-04 12:36:23 +02:00
liblzma: Handle allocation failures correctly in lzma_index_init().
Thanks to Jim Meyering.
This commit is contained in:
parent
fe00f95828
commit
8bd91918ac
1 changed files with 5 additions and 2 deletions
|
@ -398,10 +398,13 @@ extern LZMA_API(lzma_index *)
|
||||||
lzma_index_init(lzma_allocator *allocator)
|
lzma_index_init(lzma_allocator *allocator)
|
||||||
{
|
{
|
||||||
lzma_index *i = index_init_plain(allocator);
|
lzma_index *i = index_init_plain(allocator);
|
||||||
|
if (i == NULL)
|
||||||
|
return NULL;
|
||||||
|
|
||||||
index_stream *s = index_stream_init(0, 0, 1, 0, allocator);
|
index_stream *s = index_stream_init(0, 0, 1, 0, allocator);
|
||||||
if (i == NULL || s == NULL) {
|
if (s == NULL) {
|
||||||
index_stream_end(s, allocator);
|
|
||||||
lzma_free(i, allocator);
|
lzma_free(i, allocator);
|
||||||
|
return NULL;
|
||||||
}
|
}
|
||||||
|
|
||||||
index_tree_append(&i->streams, &s->node);
|
index_tree_append(&i->streams, &s->node);
|
||||||
|
|
Loading…
Reference in a new issue