From 5733e1c28b92ebbf090bea8f25e252aa40e0b9c4 Mon Sep 17 00:00:00 2001 From: Oleg Oshmyan Date: Sat, 10 Jul 2021 03:13:51 +0300 Subject: ass_face_stream: don't leak first struct if second alloc fails Bug in commit a7f67df5f96f03fab6661d90d716c16e0fab4a21, which introduced the alloc check. Before that, alloc failure would result in illegal memory access, so at least this was an improvement. Fixes CID 350862 found by Coverity Scan. --- libass/ass_font.c | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/libass/ass_font.c b/libass/ass_font.c index a7ee576..e4ce62b 100644 --- a/libass/ass_font.c +++ b/libass/ass_font.c @@ -188,8 +188,10 @@ FT_Face ass_face_stream(ASS_Library *lib, FT_Library ftlib, const char *name, *fs = *stream; FT_Stream ftstream = calloc(1, sizeof(FT_StreamRec)); - if (!ftstream) + if (!ftstream) { + free(fs); return NULL; + } ftstream->size = stream->func(stream->priv, NULL, 0, 0); ftstream->read = read_stream_font; ftstream->close = close_stream_font; -- cgit v1.2.3