diff options
author | Doug Hogan <[email protected]> | 2019-01-04 00:46:08 -0800 |
---|---|---|
committer | Doug Hogan <[email protected]> | 2019-01-08 01:11:58 -0800 |
commit | e4ecb3fd94ebae8eac89dbfb9376d78a5ac9a508 (patch) | |
tree | 71c062caef2ea083e4fff50ecc48fd1478b1d89f /lib/crypto/c_src | |
parent | 9b0739fd44adfc1a7d5b5b5f26df883cca8b9c41 (diff) | |
download | otp-e4ecb3fd94ebae8eac89dbfb9376d78a5ac9a508.tar.gz otp-e4ecb3fd94ebae8eac89dbfb9376d78a5ac9a508.tar.bz2 otp-e4ecb3fd94ebae8eac89dbfb9376d78a5ac9a508.zip |
Revamp term2point()
* Only set pptr on success
Diffstat (limited to 'lib/crypto/c_src')
-rw-r--r-- | lib/crypto/c_src/ec.c | 28 |
1 files changed, 14 insertions, 14 deletions
diff --git a/lib/crypto/c_src/ec.c b/lib/crypto/c_src/ec.c index 51da577cd0..4fb9229edb 100644 --- a/lib/crypto/c_src/ec.c +++ b/lib/crypto/c_src/ec.c @@ -268,29 +268,29 @@ static ERL_NIF_TERM point2term(ErlNifEnv* env, int term2point(ErlNifEnv* env, ERL_NIF_TERM term, EC_GROUP *group, EC_POINT **pptr) { - int ret = 0; ErlNifBinary bin; - EC_POINT *point; + EC_POINT *point = NULL; - if (!enif_inspect_binary(env,term,&bin)) { - return 0; - } + if (!enif_inspect_binary(env, term, &bin)) + goto err; - if ((*pptr = point = EC_POINT_new(group)) == NULL) { - return 0; - } + if ((point = EC_POINT_new(group)) == NULL) + goto err; /* set the point conversion form */ EC_GROUP_set_point_conversion_form(group, (point_conversion_form_t)(bin.data[0] & ~0x01)); /* extract the ec point */ - if (!EC_POINT_oct2point(group, point, bin.data, bin.size, NULL)) { - EC_POINT_free(point); - *pptr = NULL; - } else - ret = 1; + if (!EC_POINT_oct2point(group, point, bin.data, bin.size, NULL)) + goto err; - return ret; + *pptr = point; + return 1; + + err: + if (point) + EC_POINT_free(point); + return 0; } int get_ec_key(ErlNifEnv* env, |