mirror of https://github.com/qt/qthttpserver.git
Fix HTTP/2 handling leaking device if stream is not found or inactive
Move unique_ptr taking ownership of QIODevice earlier in the HTTP/2 handling to prevent it from leaking if the stream is not found or is inactive (closed or idle). The write function for devices must always take owvnership the device and destroy it when it is no longer needed. Task-number: QTBUG-137330 Pick-to: 6.8 Change-Id: I5c7df2dfaca25c382717ec9afe6607f1919475d7 Reviewed-by: Matthias Rauter <matthias.rauter@qt.io> (cherry picked from commitdda6bf7124
) Reviewed-by: Qt Cherry-pick Bot <cherrypick_bot@qt-project.org> (cherry picked from commit2441be844e
)
This commit is contained in:
parent
aa50d681c7
commit
47a047e5d5
|
@ -124,12 +124,12 @@ void QHttpServerHttp2ProtocolHandler::write(QHttpServerResponder::StatusCode sta
|
|||
void QHttpServerHttp2ProtocolHandler::write(QIODevice *data, const QHttpHeaders &headers,
|
||||
QHttpServerResponder::StatusCode status, quint32 streamId)
|
||||
{
|
||||
std::unique_ptr<QIODevice, QScopedPointerDeleteLater> input(data);
|
||||
|
||||
QHttp2Stream *stream = getStream(streamId);
|
||||
if (!stream)
|
||||
return;
|
||||
|
||||
std::unique_ptr<QIODevice, QScopedPointerDeleteLater> input(data);
|
||||
|
||||
if (!input->isOpen()) {
|
||||
if (!input->open(QIODevice::ReadOnly)) {
|
||||
// TODO Add developer error handling
|
||||
|
|
Loading…
Reference in New Issue