diff options
Diffstat (limited to '')
| -rw-r--r-- | src/lib/libcrypto/bn/bn_lib.c | 26 |
1 files changed, 17 insertions, 9 deletions
diff --git a/src/lib/libcrypto/bn/bn_lib.c b/src/lib/libcrypto/bn/bn_lib.c index a8022f6668..9787a31dbb 100644 --- a/src/lib/libcrypto/bn/bn_lib.c +++ b/src/lib/libcrypto/bn/bn_lib.c | |||
| @@ -226,11 +226,22 @@ void BN_clear_free(BIGNUM *a) | |||
| 226 | free(a); | 226 | free(a); |
| 227 | } | 227 | } |
| 228 | 228 | ||
| 229 | void | 229 | void BN_free(BIGNUM *a) |
| 230 | BN_free(BIGNUM *a) | 230 | { |
| 231 | { | 231 | if (a == NULL) return; |
| 232 | BN_clear_free(a); | 232 | bn_check_top(a); |
| 233 | } | 233 | if ((a->d != NULL) && !(BN_get_flags(a,BN_FLG_STATIC_DATA))) |
| 234 | free(a->d); | ||
| 235 | if (a->flags & BN_FLG_MALLOCED) | ||
| 236 | free(a); | ||
| 237 | else | ||
| 238 | { | ||
| 239 | #ifndef OPENSSL_NO_DEPRECATED | ||
| 240 | a->flags|=BN_FLG_FREE; | ||
| 241 | #endif | ||
| 242 | a->d = NULL; | ||
| 243 | } | ||
| 244 | } | ||
| 234 | 245 | ||
| 235 | void BN_init(BIGNUM *a) | 246 | void BN_init(BIGNUM *a) |
| 236 | { | 247 | { |
| @@ -389,10 +400,7 @@ BIGNUM *bn_expand2(BIGNUM *b, int words) | |||
| 389 | { | 400 | { |
| 390 | BN_ULONG *a = bn_expand_internal(b, words); | 401 | BN_ULONG *a = bn_expand_internal(b, words); |
| 391 | if(!a) return NULL; | 402 | if(!a) return NULL; |
| 392 | if(b->d) { | 403 | if(b->d) free(b->d); |
| 393 | OPENSSL_cleanse(b->d, b->dmax * sizeof(b->d[0])); | ||
| 394 | free(b->d); | ||
| 395 | } | ||
| 396 | b->d=a; | 404 | b->d=a; |
| 397 | b->dmax=words; | 405 | b->dmax=words; |
| 398 | } | 406 | } |
