summaryrefslogtreecommitdiffstats
path: root/crypto/bio/bio_meth.c
diff options
context:
space:
mode:
authorRich Salz <rsalz@openssl.org>2018-02-10 13:36:47 -0500
committerRich Salz <rsalz@openssl.org>2018-02-10 13:36:47 -0500
commit6dbe4dc4752484e1628e854dce46ef48faaf3384 (patch)
tree3753186af98848d6b8067206f64b007a3008821d /crypto/bio/bio_meth.c
parent4e0752535eb87b9aab4cf193f4422b5801ab7b32 (diff)
Copy name string in BIO_meth_new
Reviewed-by: Richard Levitte <levitte@openssl.org> (Merged from https://github.com/openssl/openssl/pull/5318)
Diffstat (limited to 'crypto/bio/bio_meth.c')
-rw-r--r--crypto/bio/bio_meth.c14
1 files changed, 10 insertions, 4 deletions
diff --git a/crypto/bio/bio_meth.c b/crypto/bio/bio_meth.c
index 1c5d196239..a1fff14160 100644
--- a/crypto/bio/bio_meth.c
+++ b/crypto/bio/bio_meth.c
@@ -37,16 +37,22 @@ BIO_METHOD *BIO_meth_new(int type, const char *name)
{
BIO_METHOD *biom = OPENSSL_zalloc(sizeof(BIO_METHOD));
- if (biom != NULL) {
- biom->type = type;
- biom->name = name;
+ if (biom == NULL
+ || (biom->name = OPENSSL_strdup(name)) == NULL) {
+ OPENSSL_free(biom);
+ BIOerr(BIO_F_BIO_METH_NEW, ERR_R_MALLOC_FAILURE);
+ return NULL;
}
+ biom->type = type;
return biom;
}
void BIO_meth_free(BIO_METHOD *biom)
{
- OPENSSL_free(biom);
+ if (biom != NULL) {
+ OPENSSL_free(biom->name);
+ OPENSSL_free(biom);
+ }
}
int (*BIO_meth_get_write(BIO_METHOD *biom)) (BIO *, const char *, int)