[base] 'close' callback may not use `stream->memory`.

The documentation for `FT_StreamRec::memory` states that it 'shouldn't be
touched by stream implementations'.  This is true even for internal
implementations of the 'close' callback, since it is not guaranteed that
`memory` will even be set when the 'close' callback occurs.

* src/base/ftobjs.c (new_memory_stream): stash current `memory` in
`stream->descriptor`.
(memory_stream_close): Use it.
This commit is contained in:
Ben Wagner 2023-01-12 23:45:12 -05:00 committed by Werner Lemberg
parent 0d4f887c79
commit 29f83d1dd5
1 changed files with 3 additions and 2 deletions

View File

@ -1672,7 +1672,7 @@
static void
memory_stream_close( FT_Stream stream )
{
FT_Memory memory = stream->memory;
FT_Memory memory = (FT_Memory)stream->descriptor.pointer;
FT_FREE( stream->base );
@ -1709,7 +1709,8 @@
FT_Stream_OpenMemory( stream, base, size );
stream->close = close;
stream->descriptor.pointer = memory;
stream->close = close;
*astream = stream;