From 20894d1c5e2ffaff8ee681e90956847ddad1ec5c Mon Sep 17 00:00:00 2001 From: Max Kellermann Date: Fri, 9 Sep 2016 17:56:51 +0200 Subject: [PATCH] playlist/SoundCloud: use AtScopeExit() --- src/playlist/plugins/SoundCloudPlaylistPlugin.cxx | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/src/playlist/plugins/SoundCloudPlaylistPlugin.cxx b/src/playlist/plugins/SoundCloudPlaylistPlugin.cxx index 7dcbadc3a..e18d1abab 100644 --- a/src/playlist/plugins/SoundCloudPlaylistPlugin.cxx +++ b/src/playlist/plugins/SoundCloudPlaylistPlugin.cxx @@ -28,6 +28,7 @@ #include "util/Alloc.hxx" #include "util/Error.hxx" #include "util/Domain.hxx" +#include "util/ScopeExit.hxx" #include "Log.hxx" #include @@ -317,6 +318,8 @@ soundcloud_open_uri(const char *uri, Mutex &mutex, Cond &cond) u = soundcloud_resolve(rest); } + AtScopeExit(u) { free(u); }; + if (u == nullptr) { LogWarning(soundcloud_domain, "unknown soundcloud URI"); return nullptr; @@ -324,12 +327,10 @@ soundcloud_open_uri(const char *uri, Mutex &mutex, Cond &cond) SoundCloudJsonData data; yajl_handle hand = yajl_alloc(&parse_callbacks, nullptr, &data); + AtScopeExit(hand, &data) { yajl_free(hand); }; int ret = soundcloud_parse_json(u, hand, mutex, cond); - free(u); - yajl_free(hand); - if (ret == -1) return nullptr;