From 4cfde10b7308bedcaceb5633bf633148f62292af Mon Sep 17 00:00:00 2001 From: Philip Gregor <147669098+pgregorr-amazon@users.noreply.github.com> Date: Thu, 4 Apr 2024 14:57:31 -0700 Subject: [PATCH] Android: Fix memory leak in DnssdImpl.cpp ChipDnssdStopBrowse() (#32855) * Android: Fix memory leak in ChipDnssdStopBrowse - Addressed comment by bzbarsky-apple * Addressed comment by bzbarsky-apple simplified --- src/platform/android/DnssdImpl.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/platform/android/DnssdImpl.cpp b/src/platform/android/DnssdImpl.cpp index 5a27b76c7ebae1..b272ed5a712414 100644 --- a/src/platform/android/DnssdImpl.cpp +++ b/src/platform/android/DnssdImpl.cpp @@ -219,6 +219,7 @@ CHIP_ERROR ChipDnssdStopBrowse(intptr_t browseIdentifier) env->CallVoidMethod(sBrowserObject.ObjectRef(), sStopBrowseMethod, reinterpret_cast(ctx->callback)); + chip::Platform::Delete(ctx); if (env->ExceptionCheck()) { ChipLogError(Discovery, "Java exception in ChipDnssdStopBrowse"); @@ -226,7 +227,6 @@ CHIP_ERROR ChipDnssdStopBrowse(intptr_t browseIdentifier) env->ExceptionClear(); return CHIP_JNI_ERROR_EXCEPTION_THROWN; } - chip::Platform::Delete(ctx); return CHIP_NO_ERROR; }