Skip to content

Commit 40fde61

Browse files
committed
prevent attempts to modify secp256k1_context_no_precomp
1 parent ed7c084 commit 40fde61

File tree

1 file changed

+4
-0
lines changed

1 file changed

+4
-0
lines changed

src/secp256k1.c

+4
Original file line numberDiff line numberDiff line change
@@ -99,6 +99,7 @@ secp256k1_context* secp256k1_context_clone(const secp256k1_context* ctx) {
9999
}
100100

101101
void secp256k1_context_destroy(secp256k1_context* ctx) {
102+
CHECK(ctx != secp256k1_context_no_precomp);
102103
if (ctx != NULL) {
103104
secp256k1_ecmult_context_clear(&ctx->ecmult_ctx);
104105
secp256k1_ecmult_gen_context_clear(&ctx->ecmult_gen_ctx);
@@ -108,6 +109,7 @@ void secp256k1_context_destroy(secp256k1_context* ctx) {
108109
}
109110

110111
void secp256k1_context_set_illegal_callback(secp256k1_context* ctx, void (*fun)(const char* message, void* data), const void* data) {
112+
CHECK(ctx != secp256k1_context_no_precomp);
111113
if (fun == NULL) {
112114
fun = default_illegal_callback_fn;
113115
}
@@ -116,6 +118,7 @@ void secp256k1_context_set_illegal_callback(secp256k1_context* ctx, void (*fun)(
116118
}
117119

118120
void secp256k1_context_set_error_callback(secp256k1_context* ctx, void (*fun)(const char* message, void* data), const void* data) {
121+
CHECK(ctx != secp256k1_context_no_precomp);
119122
if (fun == NULL) {
120123
fun = default_error_callback_fn;
121124
}
@@ -567,6 +570,7 @@ int secp256k1_ec_pubkey_tweak_mul(const secp256k1_context* ctx, secp256k1_pubkey
567570

568571
int secp256k1_context_randomize(secp256k1_context* ctx, const unsigned char *seed32) {
569572
VERIFY_CHECK(ctx != NULL);
573+
CHECK(ctx != secp256k1_context_no_precomp);
570574
ARG_CHECK(secp256k1_ecmult_gen_context_is_built(&ctx->ecmult_gen_ctx));
571575
secp256k1_ecmult_gen_blind(&ctx->ecmult_gen_ctx, seed32);
572576
return 1;

0 commit comments

Comments
 (0)