From c782fdb698a555fdfe6f37aeb9df46cbf633c8b1 Mon Sep 17 00:00:00 2001 From: Max Kellermann Date: Wed, 29 May 2019 15:01:23 +0200 Subject: [PATCH] Main: use AtScopeExit() to free Android objects --- src/Main.cxx | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/src/Main.cxx b/src/Main.cxx index 777e748ff..473942296 100644 --- a/src/Main.cxx +++ b/src/Main.cxx @@ -640,16 +640,16 @@ Java_org_musicpd_Bridge_run(JNIEnv *env, jclass, jobject _context, jobject _logL Java::Object::Initialise(env); Java::File::Initialise(env); Environment::Initialise(env); + AtScopeExit(env) { Environment::Deinitialise(env); }; context = new Context(env, _context); + AtScopeExit() { delete context; }; + if (_logListener != nullptr) logListener = new LogListener(env, _logListener); + AtScopeExit() { delete logListener; }; mpd_main(0, nullptr); - - delete logListener; - delete context; - Environment::Deinitialise(env); } gcc_visibility_default