From 9aac008038261ddd865d1461137ffc1b0a6c6646 Mon Sep 17 00:00:00 2001 From: Luke Dashjr Date: Tue, 1 Sep 2015 01:41:35 +0000 Subject: [PATCH] secp256k1_context_destroy: Allow NULL argument as a no-op --- include/secp256k1.h | 2 +- src/secp256k1.c | 3 +++ 2 files changed, 4 insertions(+), 1 deletion(-) diff --git a/include/secp256k1.h b/include/secp256k1.h index de6a479e..07a77bf7 100644 --- a/include/secp256k1.h +++ b/include/secp256k1.h @@ -160,7 +160,7 @@ secp256k1_context_t* secp256k1_context_clone( */ void secp256k1_context_destroy( secp256k1_context_t* ctx -) SECP256K1_ARG_NONNULL(1); +); /** Set a callback function to be called when an illegal argument is passed to * an API call. It will only trigger for violations that are mentioned diff --git a/src/secp256k1.c b/src/secp256k1.c index 3baaddae..133ab9bb 100644 --- a/src/secp256k1.c +++ b/src/secp256k1.c @@ -85,6 +85,9 @@ secp256k1_context_t* secp256k1_context_clone(const secp256k1_context_t* ctx) { } void secp256k1_context_destroy(secp256k1_context_t* ctx) { + if (!ctx) + return; + secp256k1_ecmult_context_clear(&ctx->ecmult_ctx); secp256k1_ecmult_gen_context_clear(&ctx->ecmult_gen_ctx);