From 2e2f3cb5baf1aed20c4eda08e043a2cf2515f275 Mon Sep 17 00:00:00 2001 From: Sebastian Rasmussen Date: Fri, 19 Jun 2020 16:29:07 +0800 Subject: [PATCH] [psaux] Fix memory leak (#58626). * src/psaux/psstack.c (cf2_stack_init): If `cf2_stack_init' fails to allocate the stack, return error early. --- ChangeLog | 7 +++++++ src/psaux/psstack.c | 12 ++++++------ 2 files changed, 13 insertions(+), 6 deletions(-) diff --git a/ChangeLog b/ChangeLog index b380a72ab..19967d709 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,10 @@ +2020-06-19 Sebastian Rasmussen + + [psaux] Fix memory leak (#58626). + + * src/psaux/psstack.c (cf2_stack_init): If `cf2_stack_init' fails to + allocate the stack, return error early. + 2020-06-19 Sebastian Rasmussen [base] Fix memory leak (#58624). diff --git a/src/psaux/psstack.c b/src/psaux/psstack.c index bebbba218..7ae5256ef 100644 --- a/src/psaux/psstack.c +++ b/src/psaux/psstack.c @@ -59,12 +59,12 @@ CF2_Stack stack = NULL; - if ( !FT_NEW( stack ) ) - { - /* initialize the structure; FT_NEW zeroes it */ - stack->memory = memory; - stack->error = e; - } + if ( FT_NEW( stack ) ) + return NULL; + + /* initialize the structure; FT_NEW zeroes it */ + stack->memory = memory; + stack->error = e; /* allocate the stack buffer */ if ( FT_NEW_ARRAY( stack->buffer, stackSize ) )