From fd87b9da39ca1ade9a13802db65d60c4f5c47b31 Mon Sep 17 00:00:00 2001 From: Jesper Louis Andersen Date: Thu, 6 Feb 2020 13:57:49 +0100 Subject: [PATCH] Fix a bug in sign_init/0 The code path was wrong in a lot of cases in sign_init/0 so even if it succeeded it would return a failure. Fixed by cleaning up the code. --- c_src/sign.c | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-) diff --git a/c_src/sign.c b/c_src/sign.c index 6a4e00a..292e31c 100644 --- a/c_src/sign.c +++ b/c_src/sign.c @@ -56,7 +56,8 @@ ERL_NIF_TERM enacl_crypto_sign_init(ErlNifEnv *env, int argc, if ((obj = enif_alloc_resource(enacl_sign_ctx_rtype, sizeof(enacl_sign_ctx))) == NULL) { - goto err; + ret = enacl_internal_error(env); + goto done; } obj->alive = 0; obj->state = enif_alloc(crypto_sign_statebytes()); @@ -90,8 +91,6 @@ free: release: // This also frees the mutex via the destructor enif_release_resource(obj); -err: - ret = enacl_internal_error(env); done: return ret; }