From 37ac31da4961fc4018f3d8c249be86103e04749a Mon Sep 17 00:00:00 2001 From: tedu <> Date: Wed, 7 May 2014 21:18:53 +0000 Subject: 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. --- src/lib/libcrypto/ec/ec_asn1.c | 6 ++++-- src/lib/libssl/src/crypto/ec/ec_asn1.c | 6 ++++-- 2 files changed, 8 insertions(+), 4 deletions(-) (limited to 'src') 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) if (!EC_POINT_point2oct(a->group, a->pub_key, a->conv_form, *out, buf_len, NULL)) { ECerr(EC_F_I2O_ECPUBLICKEY, ERR_R_EC_LIB); - free(*out); - *out = NULL; + if (new_buffer) { + free(*out); + *out = NULL; + } return 0; } 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) if (!EC_POINT_point2oct(a->group, a->pub_key, a->conv_form, *out, buf_len, NULL)) { ECerr(EC_F_I2O_ECPUBLICKEY, ERR_R_EC_LIB); - free(*out); - *out = NULL; + if (new_buffer) { + free(*out); + *out = NULL; + } return 0; } if (!new_buffer) -- cgit v1.2.3-55-g6feb