summaryrefslogtreecommitdiffstats
path: root/crypto/ec/ec_oct.c
diff options
context:
space:
mode:
authorRich Salz <rsalz@openssl.org>2018-04-03 17:31:16 +0200
committerRich Salz <rsalz@openssl.org>2018-04-03 17:31:16 +0200
commitcdb10bae3f773401e039c55965eb177a6f3fc160 (patch)
treec69b1b2bc385d3f600684cf8285b9ff80322c48f /crypto/ec/ec_oct.c
parentFix some errors in the mem leaks docs (diff)
downloadopenssl-cdb10bae3f773401e039c55965eb177a6f3fc160.tar.xz
openssl-cdb10bae3f773401e039c55965eb177a6f3fc160.zip
Set error code on alloc failures
Almost all *alloc failures now set an error code. Reviewed-by: Matthias St. Pierre <Matthias.St.Pierre@ncp-e.com> (Merged from https://github.com/openssl/openssl/pull/5842)
Diffstat (limited to 'crypto/ec/ec_oct.c')
-rw-r--r--crypto/ec/ec_oct.c6
1 files changed, 4 insertions, 2 deletions
diff --git a/crypto/ec/ec_oct.c b/crypto/ec/ec_oct.c
index 4a3e54ae17..32a88fb0f4 100644
--- a/crypto/ec/ec_oct.c
+++ b/crypto/ec/ec_oct.c
@@ -144,12 +144,14 @@ size_t EC_POINT_point2buf(const EC_GROUP *group, const EC_POINT *point,
{
size_t len;
unsigned char *buf;
+
len = EC_POINT_point2oct(group, point, form, NULL, 0, NULL);
if (len == 0)
return 0;
- buf = OPENSSL_malloc(len);
- if (buf == NULL)
+ if ((buf = OPENSSL_malloc(len)) == NULL) {
+ ECerr(EC_F_EC_POINT_POINT2BUF, ERR_R_MALLOC_FAILURE);
return 0;
+ }
len = EC_POINT_point2oct(group, point, form, buf, len, ctx);
if (len == 0) {
OPENSSL_free(buf);