[lzw] Preserve decompression stack when relocating to heap. * src/lzw/ftzopen.c (ft_lzwstate_stack_grow): Copy stack when relocating to heap.
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44
diff --git a/ChangeLog b/ChangeLog
index a1e66e0..5f61c1c 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,5 +1,12 @@
2021-04-27 Alexei Podtelezhnikov <apodtele@gmail.com>
+ [lzw] Preserve decompression stack when relocating to heap.
+
+ * src/lzw/ftzopen.c (ft_lzwstate_stack_grow): Copy stack when
+ relocating to heap.
+
+2021-04-27 Alexei Podtelezhnikov <apodtele@gmail.com>
+
* src/cid/cidgload.c (cid_load_glyph): Restore the glyph_length check.
2021-04-27 Werner Lemberg <wl@gnu.org>
diff --git a/src/lzw/ftzopen.c b/src/lzw/ftzopen.c
index 0c61af0..8b5b357 100644
--- a/src/lzw/ftzopen.c
+++ b/src/lzw/ftzopen.c
@@ -127,6 +127,7 @@
new_size = new_size + ( new_size >> 1 ) + 4;
+ /* if relocating to heap */
if ( state->stack == state->stack_0 )
{
state->stack = NULL;
@@ -142,9 +143,13 @@
return -1;
}
- if ( FT_RENEW_ARRAY( state->stack, old_size, new_size ) )
+ if ( FT_QRENEW_ARRAY( state->stack, old_size, new_size ) )
return -1;
+ /* if relocating to heap */
+ if ( old_size == 0 )
+ FT_MEM_COPY( state->stack, state->stack_0, FT_LZW_DEFAULT_STACK_SIZE );
+
state->stack_size = new_size;
}
return 0;