Skip to content

Commit

Permalink
Fixed double free when using free func pointer
Browse files Browse the repository at this point in the history
  • Loading branch information
ali committed Mar 11, 2022
1 parent f50f4d9 commit ce6b8df
Showing 1 changed file with 4 additions and 2 deletions.
6 changes: 4 additions & 2 deletions bcal-basic.c
Original file line number Diff line number Diff line change
Expand Up @@ -57,9 +57,11 @@ void bcal_cipher_free(bcgen_ctx_t* ctx){
return;
bc_free_fpt free_fpt;
free_fpt = (bc_free_fpt)(pgm_read_word(&(ctx->desc_ptr->free)));
if(free_fpt)
if(free_fpt) {
free_fpt((ctx->ctx));
free(ctx->ctx);
} else {
free(ctx->ctx);
}
}

void bcal_cipher_enc(void* block, const bcgen_ctx_t* ctx){
Expand Down

0 comments on commit ce6b8df

Please sign in to comment.