BaseApi: fix memleak when using QHttpMultiPart


The QHttpMultiPart object is handled by std::unique_ptr in the
HttpRequestInput class.
However, when passing the pointer to QRestAccessManager in
BaseApi::execute(), the code was simply calling release(), thus
leaking the pointer, because QRestAccessManager (or the underlying
QNetworkAccessManager) does not take the ownership of the pointer.

Fix it by introducing a new HttpRequestInput::multiPart() getter
that does not release the ownership when returning the pointer.
This way, the multipart object is still managed by the
HttpRequestInput instance.

That is, however, not a complete fix. When using a QHttpMultiPart
object, we need to guarantee that it is alive as long as the
created QNetworkReply object, because the reply stores a pointer
to this multipart object.

We cannot guarantee that the HttpRequestInput instance lives as
long as the reply, so simply take the multipart pointer from it
and reparent it to the created QNetworkReply object.

This removes the last memory leaks reported by ASAN.

Fixes: QTBUG-142907
Pick-to: 6.11
Change-Id: I293748d82cd04afce15a394f30cb8c3aa82ec718
Reviewed-by: Tatiana Borisova <tatiana.borisova@qt.io>
commit25e1c3c937996bc65031e8b1dc3be58d8ec1173b
parent2fe9ade04d13d5a843a42de0e6016f2b88ad653c
authorIvan Solovev <ivan.solovev@qt.io>
committerIvan Solovev <ivan.solovev@qt.io>
commit timeTue, 23 Dec 2025 09:16:43 +0100