aboutsummaryrefslogtreecommitdiffstats
path: root/lib/crypto
diff options
context:
space:
mode:
authorDoug Hogan <[email protected]>2019-01-03 20:36:58 -0800
committerDoug Hogan <[email protected]>2019-01-08 01:11:57 -0800
commitafda6208baa01d86efa52a31504293af2e5ec1f5 (patch)
tree2737e3bbd7fe4e435eb6e3f43635d111a807c719 /lib/crypto
parent03644ba9bcab05568870291ac5f4687c813688f5 (diff)
downloadotp-afda6208baa01d86efa52a31504293af2e5ec1f5.tar.gz
otp-afda6208baa01d86efa52a31504293af2e5ec1f5.tar.bz2
otp-afda6208baa01d86efa52a31504293af2e5ec1f5.zip
Revamp zero_terminate()
Diffstat (limited to 'lib/crypto')
-rw-r--r--lib/crypto/c_src/engine.c12
1 files changed, 8 insertions, 4 deletions
diff --git a/lib/crypto/c_src/engine.c b/lib/crypto/c_src/engine.c
index 56029638d4..cec525fc80 100644
--- a/lib/crypto/c_src/engine.c
+++ b/lib/crypto/c_src/engine.c
@@ -84,12 +84,16 @@ char *get_key_password(ErlNifEnv *env, ERL_NIF_TERM key) {
}
static int zero_terminate(ErlNifBinary bin, char **buf) {
- *buf = enif_alloc(bin.size+1);
- if (!*buf)
- return 0;
+ if ((*buf = enif_alloc(bin.size + 1)) == NULL)
+ goto err;
+
memcpy(*buf, bin.data, bin.size);
- *(*buf+bin.size) = 0;
+ *(*buf + bin.size) = 0;
+
return 1;
+
+ err:
+ return 0;
}
#endif /* HAS_ENGINE_SUPPORT */