nghttpx: Fix potential memory leak
This commit is contained in:
parent
0bb1540682
commit
ff3edc09ed
|
@ -1934,6 +1934,8 @@ StringRef get_x509_name(BlockAllocator &balloc, X509_NAME *nm) {
|
||||||
return StringRef{};
|
return StringRef{};
|
||||||
}
|
}
|
||||||
|
|
||||||
|
auto b_deleter = defer(BIO_free, b);
|
||||||
|
|
||||||
// Not documented, but it seems that X509_NAME_print_ex returns the
|
// Not documented, but it seems that X509_NAME_print_ex returns the
|
||||||
// number of bytes written into b.
|
// number of bytes written into b.
|
||||||
auto slen = X509_NAME_print_ex(b, nm, 0, XN_FLAG_RFC2253);
|
auto slen = X509_NAME_print_ex(b, nm, 0, XN_FLAG_RFC2253);
|
||||||
|
@ -1943,7 +1945,6 @@ StringRef get_x509_name(BlockAllocator &balloc, X509_NAME *nm) {
|
||||||
|
|
||||||
auto iov = make_byte_ref(balloc, slen + 1);
|
auto iov = make_byte_ref(balloc, slen + 1);
|
||||||
BIO_read(b, iov.base, slen);
|
BIO_read(b, iov.base, slen);
|
||||||
BIO_free(b);
|
|
||||||
iov.base[slen] = '\0';
|
iov.base[slen] = '\0';
|
||||||
return StringRef{iov.base, static_cast<size_t>(slen)};
|
return StringRef{iov.base, static_cast<size_t>(slen)};
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue