summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorOleg Oshmyan <chortos@inbox.lv>2021-07-10 03:13:51 +0300
committerOleg Oshmyan <chortos@inbox.lv>2021-07-10 03:13:51 +0300
commit5733e1c28b92ebbf090bea8f25e252aa40e0b9c4 (patch)
tree10831f61b4a4872ca93233a7feb9c6947d62c4ed
parent12be84bf5dc57b498bac8ece18137f0d4a29024d (diff)
downloadlibass-5733e1c28b92ebbf090bea8f25e252aa40e0b9c4.tar.bz2
libass-5733e1c28b92ebbf090bea8f25e252aa40e0b9c4.tar.xz
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.
-rw-r--r--libass/ass_font.c4
1 files changed, 3 insertions, 1 deletions
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;