diff options
author | tedu <> | 2014-05-07 21:18:53 +0000 |
---|---|---|
committer | tedu <> | 2014-05-07 21:18:53 +0000 |
commit | 37ac31da4961fc4018f3d8c249be86103e04749a (patch) | |
tree | 2e224f607c2a0965e697684d34434e80eab43f89 /src/lib | |
parent | a2563fbaa1eeaac52ff538839655d61a3eef9ae9 (diff) | |
download | openbsd-37ac31da4961fc4018f3d8c249be86103e04749a.tar.gz openbsd-37ac31da4961fc4018f3d8c249be86103e04749a.tar.bz2 openbsd-37ac31da4961fc4018f3d8c249be86103e04749a.zip |
don't free memory unless we allocated it.
reported to openssl by David Ramos (rt 3338)
stealing commit from logan, who's run away. ok miod.
Diffstat (limited to 'src/lib')
-rw-r--r-- | src/lib/libcrypto/ec/ec_asn1.c | 6 | ||||
-rw-r--r-- | src/lib/libssl/src/crypto/ec/ec_asn1.c | 6 |
2 files changed, 8 insertions, 4 deletions
diff --git a/src/lib/libcrypto/ec/ec_asn1.c b/src/lib/libcrypto/ec/ec_asn1.c index 70670a4c75..0ea0d6e2a4 100644 --- a/src/lib/libcrypto/ec/ec_asn1.c +++ b/src/lib/libcrypto/ec/ec_asn1.c | |||
@@ -1233,8 +1233,10 @@ i2o_ECPublicKey(EC_KEY * a, unsigned char **out) | |||
1233 | if (!EC_POINT_point2oct(a->group, a->pub_key, a->conv_form, | 1233 | if (!EC_POINT_point2oct(a->group, a->pub_key, a->conv_form, |
1234 | *out, buf_len, NULL)) { | 1234 | *out, buf_len, NULL)) { |
1235 | ECerr(EC_F_I2O_ECPUBLICKEY, ERR_R_EC_LIB); | 1235 | ECerr(EC_F_I2O_ECPUBLICKEY, ERR_R_EC_LIB); |
1236 | free(*out); | 1236 | if (new_buffer) { |
1237 | *out = NULL; | 1237 | free(*out); |
1238 | *out = NULL; | ||
1239 | } | ||
1238 | return 0; | 1240 | return 0; |
1239 | } | 1241 | } |
1240 | if (!new_buffer) | 1242 | if (!new_buffer) |
diff --git a/src/lib/libssl/src/crypto/ec/ec_asn1.c b/src/lib/libssl/src/crypto/ec/ec_asn1.c index 70670a4c75..0ea0d6e2a4 100644 --- a/src/lib/libssl/src/crypto/ec/ec_asn1.c +++ b/src/lib/libssl/src/crypto/ec/ec_asn1.c | |||
@@ -1233,8 +1233,10 @@ i2o_ECPublicKey(EC_KEY * a, unsigned char **out) | |||
1233 | if (!EC_POINT_point2oct(a->group, a->pub_key, a->conv_form, | 1233 | if (!EC_POINT_point2oct(a->group, a->pub_key, a->conv_form, |
1234 | *out, buf_len, NULL)) { | 1234 | *out, buf_len, NULL)) { |
1235 | ECerr(EC_F_I2O_ECPUBLICKEY, ERR_R_EC_LIB); | 1235 | ECerr(EC_F_I2O_ECPUBLICKEY, ERR_R_EC_LIB); |
1236 | free(*out); | 1236 | if (new_buffer) { |
1237 | *out = NULL; | 1237 | free(*out); |
1238 | *out = NULL; | ||
1239 | } | ||
1238 | return 0; | 1240 | return 0; |
1239 | } | 1241 | } |
1240 | if (!new_buffer) | 1242 | if (!new_buffer) |