From 86aa5dab1440e21633c547dc19aed1fb5134eaad Mon Sep 17 00:00:00 2001 From: David Benjamin Date: Sun, 7 Aug 2016 13:34:29 -0400 Subject: [PATCH] Tidy up EC_POINT_dup. The old one was written somewhat weirdly. Change-Id: I414185971a7d70105fded558da6d165570429d31 Reviewed-on: https://boringssl-review.googlesource.com/10345 CQ-Verified: CQ bot account: commit-bot@chromium.org Commit-Queue: David Benjamin Commit-Queue: Adam Langley Reviewed-by: Adam Langley --- crypto/ec/ec.c | 19 ++++++------------- 1 file changed, 6 insertions(+), 13 deletions(-) diff --git a/crypto/ec/ec.c b/crypto/ec/ec.c index 9ddd3bd5..35c26012 100644 --- a/crypto/ec/ec.c +++ b/crypto/ec/ec.c @@ -662,25 +662,18 @@ int EC_POINT_copy(EC_POINT *dest, const EC_POINT *src) { } EC_POINT *EC_POINT_dup(const EC_POINT *a, const EC_GROUP *group) { - EC_POINT *t; - int r; - if (a == NULL) { return NULL; } - t = EC_POINT_new(group); - if (t == NULL) { - OPENSSL_PUT_ERROR(EC, ERR_R_MALLOC_FAILURE); + EC_POINT *ret = EC_POINT_new(group); + if (ret == NULL || + !EC_POINT_copy(ret, a)) { + EC_POINT_free(ret); return NULL; } - r = EC_POINT_copy(t, a); - if (!r) { - EC_POINT_free(t); - return NULL; - } else { - return t; - } + + return ret; } int EC_POINT_set_to_infinity(const EC_GROUP *group, EC_POINT *point) {