mirror of
https://git.tukaani.org/xz.git
synced 2026-10-31 03:14:56 +00:00
liblzma: Make lzma_simple_coder_init() reinit-safe after alloc failure
lzma_raw_coder_init() always calls lzma_next_end() if an error occurs in filter initialization, and no other code path can call lzma_simple_coder_init(), so this change doesn't fix any bug. This is just to reduce likelyhood of future bugs.
This commit is contained in:
parent
ff834f25ae
commit
c3b290c3dc
@ -252,6 +252,17 @@ lzma_simple_coder_init(lzma_next_coder *next, const lzma_allocator *allocator,
|
||||
if (coder == NULL)
|
||||
return LZMA_MEM_ERROR;
|
||||
|
||||
// Allocate memory for the filter-specific data structure.
|
||||
if (simple_size > 0) {
|
||||
coder->simple = lzma_alloc(simple_size, allocator);
|
||||
if (coder->simple == NULL) {
|
||||
lzma_free(coder, allocator);
|
||||
return LZMA_MEM_ERROR;
|
||||
}
|
||||
} else {
|
||||
coder->simple = NULL;
|
||||
}
|
||||
|
||||
next->coder = coder;
|
||||
next->code = &simple_code;
|
||||
next->end = &simple_coder_end;
|
||||
@ -260,15 +271,6 @@ lzma_simple_coder_init(lzma_next_coder *next, const lzma_allocator *allocator,
|
||||
coder->next = LZMA_NEXT_CODER_INIT;
|
||||
coder->filter = filter;
|
||||
coder->allocated = 2 * unfiltered_max;
|
||||
|
||||
// Allocate memory for filter-specific data structure.
|
||||
if (simple_size > 0) {
|
||||
coder->simple = lzma_alloc(simple_size, allocator);
|
||||
if (coder->simple == NULL)
|
||||
return LZMA_MEM_ERROR;
|
||||
} else {
|
||||
coder->simple = NULL;
|
||||
}
|
||||
}
|
||||
|
||||
if (filters[0].options != NULL) {
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user