Skip to content

Commit

Permalink
fix(listener): credconfig leak
Browse files Browse the repository at this point in the history
  • Loading branch information
qzhuyan committed Oct 7, 2023
1 parent d0f7273 commit b35e2c4
Showing 1 changed file with 6 additions and 0 deletions.
6 changes: 6 additions & 0 deletions c_src/quicer_listener.c
Original file line number Diff line number Diff line change
Expand Up @@ -279,6 +279,7 @@ listen2(ErlNifEnv *env, __unused_parm__ int argc, const ERL_NIF_TERM argv[])
{
// TLS opt error not file content error
free(cacertfile);
free_certificate(&CredConfig);
return ERROR_TUPLE_2(ATOM_CACERTFILE);
}

Expand All @@ -288,6 +289,7 @@ listen2(ErlNifEnv *env, __unused_parm__ int argc, const ERL_NIF_TERM argv[])
if (!l_ctx)
{
free(cacertfile);
free_certificate(&CredConfig);
return ERROR_TUPLE_2(ATOM_ERROR_NOT_ENOUGH_MEMORY);
}

Expand All @@ -306,6 +308,10 @@ listen2(ErlNifEnv *env, __unused_parm__ int argc, const ERL_NIF_TERM argv[])
goto exit;
}
}
else
{ // since we don't use cacertfile, free it
free(cacertfile);
}

// Set owner for l_ctx
if (!enif_self(env, &(l_ctx->listenerPid)))
Expand Down

0 comments on commit b35e2c4

Please sign in to comment.