Welcome to mirror list, hosted at ThFree Co, Russian Federation.

github.com/mono/boringssl.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
path: root/crypto/dh
diff options
context:
space:
mode:
authorDavid Benjamin <davidben@chromium.org>2015-04-22 20:50:28 +0300
committerAdam Langley <agl@google.com>2015-05-05 02:05:17 +0300
commit22ccc2d8f1e0a3d19b98324d502322db8d89624f (patch)
tree634d6618b5a8d25cbddb5e080840f09a58657027 /crypto/dh
parentde95d262ab448f8582b8192c3a94e9c10acdb771 (diff)
Remove unnecessary NULL checks, part 1.
First batch of the alphabet. Change-Id: If4e60f4fbb69e04eb4b70aa1b2240e329251bfa5 Reviewed-on: https://boringssl-review.googlesource.com/4514 Reviewed-by: Adam Langley <agl@google.com>
Diffstat (limited to 'crypto/dh')
-rw-r--r--crypto/dh/dh.c13
-rw-r--r--crypto/dh/dh_impl.c4
-rw-r--r--crypto/dh/dh_test.c32
3 files changed, 15 insertions, 34 deletions
diff --git a/crypto/dh/dh.c b/crypto/dh/dh.c
index 77ebb1d1..ab7ed8b7 100644
--- a/crypto/dh/dh.c
+++ b/crypto/dh/dh.c
@@ -179,9 +179,7 @@ static int int_dh_bn_cpy(BIGNUM **dst, const BIGNUM *src) {
}
}
- if (*dst) {
- BN_free(*dst);
- }
+ BN_free(*dst);
*dst = a;
return 1;
}
@@ -204,11 +202,10 @@ static int int_dh_param_copy(DH *to, const DH *from, int is_x942) {
return 0;
}
- if (to->seed) {
- OPENSSL_free(to->seed);
- to->seed = NULL;
- to->seedlen = 0;
- }
+ OPENSSL_free(to->seed);
+ to->seed = NULL;
+ to->seedlen = 0;
+
if (from->seed) {
to->seed = BUF_memdup(from->seed, from->seedlen);
if (!to->seed) {
diff --git a/crypto/dh/dh_impl.c b/crypto/dh/dh_impl.c
index 81d777d0..f2694126 100644
--- a/crypto/dh/dh_impl.c
+++ b/crypto/dh/dh_impl.c
@@ -245,10 +245,10 @@ err:
OPENSSL_PUT_ERROR(DH, generate_key, ERR_R_BN_LIB);
}
- if (pub_key != NULL && dh->pub_key == NULL) {
+ if (dh->pub_key == NULL) {
BN_free(pub_key);
}
- if (priv_key != NULL && dh->priv_key == NULL) {
+ if (dh->priv_key == NULL) {
BN_free(priv_key);
}
BN_CTX_free(ctx);
diff --git a/crypto/dh/dh_test.c b/crypto/dh/dh_test.c
index 836b3b22..a1fc83fd 100644
--- a/crypto/dh/dh_test.c
+++ b/crypto/dh/dh_test.c
@@ -189,18 +189,10 @@ int main(int argc, char *argv[]) {
err:
ERR_print_errors_fp(stderr);
- if (abuf != NULL) {
- OPENSSL_free(abuf);
- }
- if (bbuf != NULL) {
- OPENSSL_free(bbuf);
- }
- if (b != NULL) {
- DH_free(b);
- }
- if (a != NULL) {
- DH_free(a);
- }
+ OPENSSL_free(abuf);
+ OPENSSL_free(bbuf);
+ DH_free(b);
+ DH_free(a);
return ret;
}
@@ -493,18 +485,10 @@ bad_err:
ERR_print_errors_fp(stderr);
err:
- if (Z1 != NULL) {
- OPENSSL_free(Z1);
- }
- if (Z2 != NULL) {
- OPENSSL_free(Z2);
- }
- if (dhA != NULL) {
- DH_free(dhA);
- }
- if (dhB != NULL) {
- DH_free(dhB);
- }
+ OPENSSL_free(Z1);
+ OPENSSL_free(Z2);
+ DH_free(dhA);
+ DH_free(dhB);
fprintf(stderr, "Test failed RFC5114 set %d\n", i + 1);
return 0;