Skip to content

Commit 9a05cf5

Browse files
bzbarsky-applepull[bot]
authored andcommitted
Make sure we don't double-close exchanges in OTA if an exchange times out. (#24818)
Fixes #24329
1 parent 8459de9 commit 9a05cf5

File tree

1 file changed

+6
-0
lines changed

1 file changed

+6
-0
lines changed

src/app/clusters/ota-requestor/DefaultOTARequestor.h

+6
Original file line numberDiff line numberDiff line change
@@ -173,6 +173,12 @@ class DefaultOTARequestor : public OTARequestorInterface, public BDXDownloader::
173173
void OnResponseTimeout(chip::Messaging::ExchangeContext * ec) override
174174
{
175175
ChipLogError(BDX, "exchange timed out");
176+
// Null out mExchangeCtx before calling OnDownloadTimeout, in case
177+
// the downloader decides to call Reset() on us. If we don't, we
178+
// will end up closing the exchange from Reset and then the caller
179+
// will close it _again_ (see API documentation for
180+
// OnResponseTimeout), which will lead to refcount underflow.
181+
mExchangeCtx = nullptr;
176182
if (mDownloader != nullptr)
177183
{
178184
mDownloader->OnDownloadTimeout();

0 commit comments

Comments
 (0)