QHttpHeaders: add a missing detach()

Before calling a mutable member function (in this case,
QList::reserve()) on one of the Private members, we need to ensure
exclusive ownership of our external state, otherwise we have a Data
Race, because QList::reserve() is not thread-safe (only re-entrant).

Pick-to: 6.7
Change-Id: I1249de9449865cbf6ab519b0d38b3bf4e743f16d
Reviewed-by: Juha Vuolle <juha.vuolle@qt.io>
This commit is contained in:
Marc Mutz 2024-01-25 18:50:19 +01:00
parent 55ee5481bc
commit 119a6b5186

View File

@ -1040,6 +1040,7 @@ qsizetype QHttpHeaders::size() const noexcept
*/
void QHttpHeaders::reserve(qsizetype size)
{
d.detach();
d->headers.reserve(size);
}