summaryrefslogtreecommitdiff
path: root/lib
diff options
context:
space:
mode:
authorTed Unangst <tedu@cvs.openbsd.org>2014-05-07 21:18:54 +0000
committerTed Unangst <tedu@cvs.openbsd.org>2014-05-07 21:18:54 +0000
commitcdabd6d89101b4aa090a0f858b81947548abbee6 (patch)
tree621f3afed2b594c5bd06beaf07ccdf01f3214a4b /lib
parent8f946eb98423a3675e0d96d8a2ba5651c9e6685e (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/libcrypto/ec/ec_asn1.c6
1 files changed, 4 insertions, 2 deletions
diff --git a/lib/libcrypto/ec/ec_asn1.c b/lib/libcrypto/ec/ec_asn1.c
index 70670a4c750..0ea0d6e2a43 100644
--- a/lib/libcrypto/ec/ec_asn1.c
+++ b/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)