Skip to content

Commit

Permalink
Add Null check for a function pointer that might not be set (#184) (#185
Browse files Browse the repository at this point in the history
)

It is possible that the pkinfo of the used pk contect is uninitialized. Add a check to make sure it has a free function before calling it
  • Loading branch information
jmartinez-silabs authored Apr 16, 2024
1 parent cb3ca63 commit e5ca9a7
Showing 1 changed file with 2 additions and 1 deletion.
3 changes: 2 additions & 1 deletion matter/mbedtls/tinycrypt/src/pk.c
Original file line number Diff line number Diff line change
Expand Up @@ -95,8 +95,9 @@ void mbedtls_pk_free(mbedtls_pk_context *ctx) {
if (ctx == NULL)
return;

if (ctx->pk_info != NULL)
if ((ctx->pk_info != NULL) && (ctx->pk_info->ctx_free_func != NULL)) {
ctx->pk_info->ctx_free_func(ctx->pk_ctx);
}

mbedtls_platform_zeroize(ctx, sizeof(mbedtls_pk_context));
}
Expand Down

0 comments on commit e5ca9a7

Please sign in to comment.