Tests: Fix memory leaks in test_block_header.
[xz/debian.git] / src / liblzma / simple / simple_decoder.c
blobdc4d241511016c5f36442f60fc9fe1ce278f9cb2
1 ///////////////////////////////////////////////////////////////////////////////
2 //
3 /// \file simple_decoder.c
4 /// \brief Properties decoder for simple filters
5 //
6 // Author: Lasse Collin
7 //
8 // This file has been put into the public domain.
9 // You can do whatever you want with this file.
11 ///////////////////////////////////////////////////////////////////////////////
13 #include "simple_decoder.h"
16 extern lzma_ret
17 lzma_simple_props_decode(void **options, const lzma_allocator *allocator,
18 const uint8_t *props, size_t props_size)
20 if (props_size == 0)
21 return LZMA_OK;
23 if (props_size != 4)
24 return LZMA_OPTIONS_ERROR;
26 lzma_options_bcj *opt = lzma_alloc(
27 sizeof(lzma_options_bcj), allocator);
28 if (opt == NULL)
29 return LZMA_MEM_ERROR;
31 opt->start_offset = read32le(props);
33 // Don't leave an options structure allocated if start_offset is zero.
34 if (opt->start_offset == 0)
35 lzma_free(opt, allocator);
36 else
37 *options = opt;
39 return LZMA_OK;