summaryrefslogtreecommitdiff
path: root/src/lib/libcrypto/asn1/a_bitstr.c
diff options
context:
space:
mode:
authorderaadt <>2014-04-21 11:37:41 +0000
committerderaadt <>2014-04-21 11:37:41 +0000
commita13698710d1bf0bac4832733da5c86886601b5d4 (patch)
treead42acc3896c553cb79781bc3a1ead69a74d55a3 /src/lib/libcrypto/asn1/a_bitstr.c
parent6a6b6afb12953d4537a41790daa6abaad39258c5 (diff)
downloadopenbsd-a13698710d1bf0bac4832733da5c86886601b5d4.tar.gz
openbsd-a13698710d1bf0bac4832733da5c86886601b5d4.tar.bz2
openbsd-a13698710d1bf0bac4832733da5c86886601b5d4.zip
improve realloc/calloc/malloc patterns; ok guenther
Diffstat (limited to 'src/lib/libcrypto/asn1/a_bitstr.c')
-rw-r--r--src/lib/libcrypto/asn1/a_bitstr.c8
1 files changed, 2 insertions, 6 deletions
diff --git a/src/lib/libcrypto/asn1/a_bitstr.c b/src/lib/libcrypto/asn1/a_bitstr.c
index c578ce6279..f3cce8b536 100644
--- a/src/lib/libcrypto/asn1/a_bitstr.c
+++ b/src/lib/libcrypto/asn1/a_bitstr.c
@@ -153,7 +153,7 @@ c2i_ASN1_BIT_STRING(ASN1_BIT_STRING **a, const unsigned char **pp, long len)
153 153
154 if (len-- > 1) /* using one because of the bits left byte */ 154 if (len-- > 1) /* using one because of the bits left byte */
155 { 155 {
156 s = (unsigned char *)malloc((int)len); 156 s = malloc((int)len);
157 if (s == NULL) { 157 if (s == NULL) {
158 i = ERR_R_MALLOC_FAILURE; 158 i = ERR_R_MALLOC_FAILURE;
159 goto err; 159 goto err;
@@ -203,11 +203,7 @@ ASN1_BIT_STRING_set_bit(ASN1_BIT_STRING *a, int n, int value)
203 if ((a->length < (w + 1)) || (a->data == NULL)) { 203 if ((a->length < (w + 1)) || (a->data == NULL)) {
204 if (!value) 204 if (!value)
205 return(1); /* Don't need to set */ 205 return(1); /* Don't need to set */
206 if (a->data == NULL) 206 c = OPENSSL_realloc_clean(a->data, a->length, w + 1);
207 c = (unsigned char *)malloc(w + 1);
208 else
209 c = (unsigned char *)OPENSSL_realloc_clean(a->data,
210 a->length, w + 1);
211 if (c == NULL) { 207 if (c == NULL) {
212 ASN1err(ASN1_F_ASN1_BIT_STRING_SET_BIT, ERR_R_MALLOC_FAILURE); 208 ASN1err(ASN1_F_ASN1_BIT_STRING_SET_BIT, ERR_R_MALLOC_FAILURE);
213 return 0; 209 return 0;