diff options
author | Doug Hogan <[email protected]> | 2019-01-03 20:49:21 -0800 |
---|---|---|
committer | Doug Hogan <[email protected]> | 2019-01-08 01:11:57 -0800 |
commit | 8b2e00ca9c9a92b1088ddeb75a3764bf198ab19f (patch) | |
tree | 379e67b162c0cd4fe9a0703017f9a145d8926696 /lib/crypto | |
parent | f16e0061a9bdbab39bc25781efbae736710c76af (diff) | |
download | otp-8b2e00ca9c9a92b1088ddeb75a3764bf198ab19f.tar.gz otp-8b2e00ca9c9a92b1088ddeb75a3764bf198ab19f.tar.bz2 otp-8b2e00ca9c9a92b1088ddeb75a3764bf198ab19f.zip |
Revamp engine_free_nif()
* Add error handling for all OpenSSL calls.
Diffstat (limited to 'lib/crypto')
-rw-r--r-- | lib/crypto/c_src/engine.c | 15 |
1 files changed, 10 insertions, 5 deletions
diff --git a/lib/crypto/c_src/engine.c b/lib/crypto/c_src/engine.c index 1398e315aa..9a3793180d 100644 --- a/lib/crypto/c_src/engine.c +++ b/lib/crypto/c_src/engine.c @@ -194,13 +194,18 @@ ERL_NIF_TERM engine_free_nif(ErlNifEnv* env, int argc, const ERL_NIF_TERM argv[] struct engine_ctx *ctx; // Get Engine - if (!enif_get_resource(env, argv[0], engine_ctx_rtype, (void**)&ctx)) { - PRINTF_ERR0("engine_free_nif Leaved: Parameter not an engine resource object"); - return enif_make_badarg(env); - } + if (argc != 1) + goto bad_arg; + if (!enif_get_resource(env, argv[0], engine_ctx_rtype, (void**)&ctx)) + goto bad_arg; - ENGINE_free(ctx->engine); + if (!ENGINE_free(ctx->engine)) + goto err; return atom_ok; + + bad_arg: + err: + return enif_make_badarg(env); #else return atom_notsup; #endif |