diff options
author | Ted Unangst <tedu@cvs.openbsd.org> | 2014-05-07 21:18:54 +0000 |
---|---|---|
committer | Ted Unangst <tedu@cvs.openbsd.org> | 2014-05-07 21:18:54 +0000 |
commit | c262d59aa1c5a3e89984db2c67c61f02f02517d7 (patch) | |
tree | e6662939916751c1e66d7f58909a4aae5f5209bb /lib | |
parent | d505e15f0c7123c5297d61e1121b371034efa311 (diff) |
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 'lib')
-rw-r--r-- | lib/libssl/src/crypto/ec/ec_asn1.c | 6 |
1 files changed, 4 insertions, 2 deletions
diff --git a/lib/libssl/src/crypto/ec/ec_asn1.c b/lib/libssl/src/crypto/ec/ec_asn1.c index 70670a4c750..0ea0d6e2a43 100644 --- a/lib/libssl/src/crypto/ec/ec_asn1.c +++ b/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) |