summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authormmcc <>2015-12-23 20:37:23 +0000
committermmcc <>2015-12-23 20:37:23 +0000
commit9ea87938324c8e5274af7fb1c3e832473ea5cdbe (patch)
tree6a0bcb7c2382a4d5e6eb2313bd14754a09b5deb7
parent6f23276bbcf82076c4ba8d386890d184a7e7f0a6 (diff)
downloadopenbsd-9ea87938324c8e5274af7fb1c3e832473ea5cdbe.tar.gz
openbsd-9ea87938324c8e5274af7fb1c3e832473ea5cdbe.tar.bz2
openbsd-9ea87938324c8e5274af7fb1c3e832473ea5cdbe.zip
remove NULL-checks before free()
-rw-r--r--src/lib/libcrypto/asn1/asn_pack.c8
-rw-r--r--src/lib/libcrypto/bio/bss_bio.c8
-rw-r--r--src/lib/libcrypto/comp/c_zlib.c14
-rw-r--r--src/lib/libssl/src/crypto/asn1/asn_pack.c8
-rw-r--r--src/lib/libssl/src/crypto/bio/bss_bio.c8
-rw-r--r--src/lib/libssl/src/crypto/comp/c_zlib.c14
6 files changed, 22 insertions, 38 deletions
diff --git a/src/lib/libcrypto/asn1/asn_pack.c b/src/lib/libcrypto/asn1/asn_pack.c
index f010f87bbd..65f4b9bf97 100644
--- a/src/lib/libcrypto/asn1/asn_pack.c
+++ b/src/lib/libcrypto/asn1/asn_pack.c
@@ -1,4 +1,4 @@
1/* $OpenBSD: asn_pack.c,v 1.14 2014/07/11 13:41:59 miod Exp $ */ 1/* $OpenBSD: asn_pack.c,v 1.15 2015/12/23 20:37:23 mmcc Exp $ */
2/* Written by Dr Stephen N Henson (steve@openssl.org) for the OpenSSL 2/* Written by Dr Stephen N Henson (steve@openssl.org) for the OpenSSL
3 * project 1999. 3 * project 1999.
4 */ 4 */
@@ -180,10 +180,8 @@ ASN1_item_pack(void *obj, const ASN1_ITEM *it, ASN1_STRING **oct)
180 } else 180 } else
181 octmp = *oct; 181 octmp = *oct;
182 182
183 if (octmp->data) { 183 free(octmp->data);
184 free(octmp->data); 184 octmp->data = NULL;
185 octmp->data = NULL;
186 }
187 185
188 if (!(octmp->length = ASN1_item_i2d(obj, &octmp->data, it))) { 186 if (!(octmp->length = ASN1_item_i2d(obj, &octmp->data, it))) {
189 ASN1err(ASN1_F_ASN1_ITEM_PACK, ASN1_R_ENCODE_ERROR); 187 ASN1err(ASN1_F_ASN1_ITEM_PACK, ASN1_R_ENCODE_ERROR);
diff --git a/src/lib/libcrypto/bio/bss_bio.c b/src/lib/libcrypto/bio/bss_bio.c
index b5f13eb35c..c817910d93 100644
--- a/src/lib/libcrypto/bio/bss_bio.c
+++ b/src/lib/libcrypto/bio/bss_bio.c
@@ -1,4 +1,4 @@
1/* $OpenBSD: bss_bio.c,v 1.21 2015/10/30 15:45:57 miod Exp $ */ 1/* $OpenBSD: bss_bio.c,v 1.22 2015/12/23 20:37:23 mmcc Exp $ */
2/* ==================================================================== 2/* ====================================================================
3 * Copyright (c) 1998-2003 The OpenSSL Project. All rights reserved. 3 * Copyright (c) 1998-2003 The OpenSSL Project. All rights reserved.
4 * 4 *
@@ -500,10 +500,8 @@ bio_ctrl(BIO *bio, int cmd, long num, void *ptr)
500 size_t new_size = num; 500 size_t new_size = num;
501 501
502 if (b->size != new_size) { 502 if (b->size != new_size) {
503 if (b->buf) { 503 free(b->buf);
504 free(b->buf); 504 b->buf = NULL;
505 b->buf = NULL;
506 }
507 b->size = new_size; 505 b->size = new_size;
508 } 506 }
509 ret = 1; 507 ret = 1;
diff --git a/src/lib/libcrypto/comp/c_zlib.c b/src/lib/libcrypto/comp/c_zlib.c
index 4951ade810..d9a3359313 100644
--- a/src/lib/libcrypto/comp/c_zlib.c
+++ b/src/lib/libcrypto/comp/c_zlib.c
@@ -1,4 +1,4 @@
1/* $OpenBSD: c_zlib.c,v 1.17 2014/11/03 16:58:28 tedu Exp $ */ 1/* $OpenBSD: c_zlib.c,v 1.18 2015/12/23 20:37:23 mmcc Exp $ */
2#include <stdio.h> 2#include <stdio.h>
3#include <stdlib.h> 3#include <stdlib.h>
4#include <string.h> 4#include <string.h>
@@ -524,18 +524,14 @@ bio_zlib_ctrl(BIO *b, int cmd, long num, void *ptr)
524 } 524 }
525 525
526 if (ibs != -1) { 526 if (ibs != -1) {
527 if (ctx->ibuf) { 527 free(ctx->ibuf);
528 free(ctx->ibuf); 528 ctx->ibuf = NULL;
529 ctx->ibuf = NULL;
530 }
531 ctx->ibufsize = ibs; 529 ctx->ibufsize = ibs;
532 } 530 }
533 531
534 if (obs != -1) { 532 if (obs != -1) {
535 if (ctx->obuf) { 533 free(ctx->obuf);
536 free(ctx->obuf); 534 ctx->obuf = NULL;
537 ctx->obuf = NULL;
538 }
539 ctx->obufsize = obs; 535 ctx->obufsize = obs;
540 } 536 }
541 ret = 1; 537 ret = 1;
diff --git a/src/lib/libssl/src/crypto/asn1/asn_pack.c b/src/lib/libssl/src/crypto/asn1/asn_pack.c
index f010f87bbd..65f4b9bf97 100644
--- a/src/lib/libssl/src/crypto/asn1/asn_pack.c
+++ b/src/lib/libssl/src/crypto/asn1/asn_pack.c
@@ -1,4 +1,4 @@
1/* $OpenBSD: asn_pack.c,v 1.14 2014/07/11 13:41:59 miod Exp $ */ 1/* $OpenBSD: asn_pack.c,v 1.15 2015/12/23 20:37:23 mmcc Exp $ */
2/* Written by Dr Stephen N Henson (steve@openssl.org) for the OpenSSL 2/* Written by Dr Stephen N Henson (steve@openssl.org) for the OpenSSL
3 * project 1999. 3 * project 1999.
4 */ 4 */
@@ -180,10 +180,8 @@ ASN1_item_pack(void *obj, const ASN1_ITEM *it, ASN1_STRING **oct)
180 } else 180 } else
181 octmp = *oct; 181 octmp = *oct;
182 182
183 if (octmp->data) { 183 free(octmp->data);
184 free(octmp->data); 184 octmp->data = NULL;
185 octmp->data = NULL;
186 }
187 185
188 if (!(octmp->length = ASN1_item_i2d(obj, &octmp->data, it))) { 186 if (!(octmp->length = ASN1_item_i2d(obj, &octmp->data, it))) {
189 ASN1err(ASN1_F_ASN1_ITEM_PACK, ASN1_R_ENCODE_ERROR); 187 ASN1err(ASN1_F_ASN1_ITEM_PACK, ASN1_R_ENCODE_ERROR);
diff --git a/src/lib/libssl/src/crypto/bio/bss_bio.c b/src/lib/libssl/src/crypto/bio/bss_bio.c
index b5f13eb35c..c817910d93 100644
--- a/src/lib/libssl/src/crypto/bio/bss_bio.c
+++ b/src/lib/libssl/src/crypto/bio/bss_bio.c
@@ -1,4 +1,4 @@
1/* $OpenBSD: bss_bio.c,v 1.21 2015/10/30 15:45:57 miod Exp $ */ 1/* $OpenBSD: bss_bio.c,v 1.22 2015/12/23 20:37:23 mmcc Exp $ */
2/* ==================================================================== 2/* ====================================================================
3 * Copyright (c) 1998-2003 The OpenSSL Project. All rights reserved. 3 * Copyright (c) 1998-2003 The OpenSSL Project. All rights reserved.
4 * 4 *
@@ -500,10 +500,8 @@ bio_ctrl(BIO *bio, int cmd, long num, void *ptr)
500 size_t new_size = num; 500 size_t new_size = num;
501 501
502 if (b->size != new_size) { 502 if (b->size != new_size) {
503 if (b->buf) { 503 free(b->buf);
504 free(b->buf); 504 b->buf = NULL;
505 b->buf = NULL;
506 }
507 b->size = new_size; 505 b->size = new_size;
508 } 506 }
509 ret = 1; 507 ret = 1;
diff --git a/src/lib/libssl/src/crypto/comp/c_zlib.c b/src/lib/libssl/src/crypto/comp/c_zlib.c
index 4951ade810..d9a3359313 100644
--- a/src/lib/libssl/src/crypto/comp/c_zlib.c
+++ b/src/lib/libssl/src/crypto/comp/c_zlib.c
@@ -1,4 +1,4 @@
1/* $OpenBSD: c_zlib.c,v 1.17 2014/11/03 16:58:28 tedu Exp $ */ 1/* $OpenBSD: c_zlib.c,v 1.18 2015/12/23 20:37:23 mmcc Exp $ */
2#include <stdio.h> 2#include <stdio.h>
3#include <stdlib.h> 3#include <stdlib.h>
4#include <string.h> 4#include <string.h>
@@ -524,18 +524,14 @@ bio_zlib_ctrl(BIO *b, int cmd, long num, void *ptr)
524 } 524 }
525 525
526 if (ibs != -1) { 526 if (ibs != -1) {
527 if (ctx->ibuf) { 527 free(ctx->ibuf);
528 free(ctx->ibuf); 528 ctx->ibuf = NULL;
529 ctx->ibuf = NULL;
530 }
531 ctx->ibufsize = ibs; 529 ctx->ibufsize = ibs;
532 } 530 }
533 531
534 if (obs != -1) { 532 if (obs != -1) {
535 if (ctx->obuf) { 533 free(ctx->obuf);
536 free(ctx->obuf); 534 ctx->obuf = NULL;
537 ctx->obuf = NULL;
538 }
539 ctx->obufsize = obs; 535 ctx->obufsize = obs;
540 } 536 }
541 ret = 1; 537 ret = 1;