1
0
Fork 0
mirror of https://git.tukaani.org/xz.git synced 2024-04-04 12:36:23 +02:00

Add the trailing '\0' to lzma_extra.data as the API header

already documents.
This commit is contained in:
Lasse Collin 2008-01-23 22:02:38 +02:00
parent ed40dc5a2c
commit e5fdec93e2

View file

@ -366,7 +366,8 @@ process(lzma_coder *coder, lzma_allocator *allocator)
coder->extra_tail->size = (size_t)(coder->tmp); coder->extra_tail->size = (size_t)(coder->tmp);
coder->tmp = 0; coder->tmp = 0;
uint8_t *d = lzma_alloc((size_t)(coder->extra_tail->size), // We reserve space for the trailing '\0' too.
uint8_t *d = lzma_alloc((size_t)(coder->extra_tail->size) + 1,
allocator); allocator);
if (d == NULL) if (d == NULL)
return LZMA_MEM_ERROR; return LZMA_MEM_ERROR;
@ -383,6 +384,7 @@ process(lzma_coder *coder, lzma_allocator *allocator)
(size_t)(coder->extra_tail->size)); (size_t)(coder->extra_tail->size));
if ((size_t)(coder->extra_tail->size) == coder->pos) { if ((size_t)(coder->extra_tail->size) == coder->pos) {
coder->extra_tail->data[coder->pos] = '\0';
coder->pos = 0; coder->pos = 0;
coder->todo_count = 0; coder->todo_count = 0;
coder->sequence = SEQ_EXTRA_ALLOC; coder->sequence = SEQ_EXTRA_ALLOC;