From cadd186f1be1e2c49e91c4d8bdfdc9dc73fed292 Mon Sep 17 00:00:00 2001 From: Max Kellermann Date: Tue, 8 Nov 2016 15:10:38 +0100 Subject: [PATCH] output/jack: use AtScopeExit() --- src/output/plugins/JackOutputPlugin.cxx | 14 +++----------- 1 file changed, 3 insertions(+), 11 deletions(-) diff --git a/src/output/plugins/JackOutputPlugin.cxx b/src/output/plugins/JackOutputPlugin.cxx index 7d05e7a73..b2f507f8a 100644 --- a/src/output/plugins/JackOutputPlugin.cxx +++ b/src/output/plugins/JackOutputPlugin.cxx @@ -22,6 +22,7 @@ #include "../OutputAPI.hxx" #include "../Wrapper.hxx" #include "config/ConfigError.hxx" +#include "util/ScopeExit.hxx" #include "util/ConstBuffer.hxx" #include "util/IterableSplitString.hxx" #include "util/Error.hxx" @@ -557,6 +558,8 @@ JackOutput::Start(Error &error) jports = nullptr; } + AtScopeExit(jports) { free(jports); }; + assert(num_dports > 0); const char *duplicate_port = nullptr; @@ -584,10 +587,6 @@ JackOutput::Start(Error &error) if (ret != 0) { error.Format(jack_output_domain, "Not a valid JACK port: %s", dports[i]); - - if (jports != nullptr) - free(jports); - Stop(); return false; } @@ -604,18 +603,11 @@ JackOutput::Start(Error &error) error.Format(jack_output_domain, "Not a valid JACK port: %s", duplicate_port); - - if (jports != nullptr) - free(jports); - Stop(); return false; } } - if (jports != nullptr) - free(jports); - return true; }