QDtls - remove redundant RAII struct

As noted by LCOV, the part with q_BIO_free(bio) was never executed
since we were taking the result from QScopedPointer before returning.
While it's a what RAII idiom is for, there is quite a low probability
that SSL_set_bio() one day will start throwing exceptions.

Pick-to: 6.0
Pick-to: 5.15
Change-Id: Id24e480dac34166c627b71bb2972de558c644339
Reviewed-by: Timur Pocheptsov <timur.pocheptsov@qt.io>
bb10
Timur Pocheptsov 2020-11-19 10:20:18 +01:00
parent 1d7189f5b3
commit 16f4ce89ed
1 changed files with 1 additions and 13 deletions

View File

@ -170,16 +170,6 @@ void delete_bio_method(BIO_METHOD *method)
q_BIO_meth_free(method);
}
// The 'deleter' for QScopedPointer<BIO>.
struct bio_deleter
{
static void cleanup(BIO *bio)
{
if (bio)
q_BIO_free(bio);
}
};
// The path MTU discovery is non-trivial: it's a mix of getsockopt/setsockopt
// (IP_MTU/IP6_MTU/IP_MTU_DISCOVER) and fallback MTU values. It's not
// supported on all platforms, worse so - imposes specific requirements on
@ -746,8 +736,7 @@ bool DtlsState::initBIO(QDtlsBasePrivate *dtlsBase)
q_BIO_meth_set_puts(biom, dtlsbio::q_dgram_puts);
q_BIO_meth_set_ctrl(biom, dtlsbio::q_dgram_ctrl);
QScopedPointer<BIO, dtlsutil::bio_deleter> newBio(q_BIO_new(biom));
BIO *bio = newBio.data();
BIO *bio = q_BIO_new(biom);
if (!bio) {
dtlsBase->setDtlsError(QDtlsError::TlsInitializationError,
msgFunctionFailed("BIO_new"));
@ -755,7 +744,6 @@ bool DtlsState::initBIO(QDtlsBasePrivate *dtlsBase)
}
q_SSL_set_bio(tlsConnection.data(), bio, bio);
newBio.take();
bioMethod.swap(customMethod);