diff --git a/src/common/cryptohash_openssl.c b/src/common/cryptohash_openssl.c index e5233daab6..02dec1fd1b 100644 --- a/src/common/cryptohash_openssl.c +++ b/src/common/cryptohash_openssl.c @@ -72,14 +72,15 @@ pg_cryptohash_create(pg_cryptohash_type type) ctx = ALLOC(sizeof(pg_cryptohash_ctx)); if (ctx == NULL) return NULL; + explicit_bzero(ctx, sizeof(pg_cryptohash_ctx)); state = ALLOC(sizeof(pg_cryptohash_state)); if (state == NULL) { - explicit_bzero(ctx, sizeof(pg_cryptohash_ctx)); FREE(ctx); return NULL; } + explicit_bzero(state, sizeof(pg_cryptohash_state)); ctx->data = state; ctx->type = type; @@ -97,8 +98,6 @@ pg_cryptohash_create(pg_cryptohash_type type) if (state->evpctx == NULL) { - explicit_bzero(state, sizeof(pg_cryptohash_state)); - explicit_bzero(ctx, sizeof(pg_cryptohash_ctx)); #ifndef FRONTEND ereport(ERROR, (errcode(ERRCODE_OUT_OF_MEMORY),