From 11043cb6a1098c288c3100d0737749541253f61d Mon Sep 17 00:00:00 2001 From: Shuanglei Tao Date: Tue, 7 Feb 2023 08:56:44 +0800 Subject: [PATCH] free string returned by mpv --- source/views/context_menu.cpp | 3 ++- source/views/quickview.cpp | 3 ++- 2 files changed, 4 insertions(+), 2 deletions(-) diff --git a/source/views/context_menu.cpp b/source/views/context_menu.cpp index 8b9ccf2..7953227 100644 --- a/source/views/context_menu.cpp +++ b/source/views/context_menu.cpp @@ -246,7 +246,7 @@ void ContextMenu::drawAudioDeviceList() { void ContextMenu::drawTracklist(const char *type, const char *prop) { auto items = mpv->trackList(); - auto value = mpv->property(prop); + char *value = mpv->property(prop); if (ImGui::BeginMenuEx("Tracks", ICON_FA_LIST)) { if (ImGui::MenuItem("Disable", nullptr, strcmp(value, "no") == 0)) mpv->commandv("cycle-values", prop, "no", "auto", nullptr); @@ -259,6 +259,7 @@ void ContextMenu::drawTracklist(const char *type, const char *prop) { } ImGui::EndMenu(); } + mpv_free(value); } void ContextMenu::drawChapterlist(std::vector items) { diff --git a/source/views/quickview.cpp b/source/views/quickview.cpp index f6719c1..e53eef7 100644 --- a/source/views/quickview.cpp +++ b/source/views/quickview.cpp @@ -86,9 +86,10 @@ bool Quickview::toggleButton(bool toggle, const char *tooltip) { void Quickview::drawTracks(const char *type, const char *prop) { ImGui::Text("Tracks"); alignRight(ICON_FA_TOGGLE_ON); - const char *state = mpv->property(prop); + char *state = mpv->property(prop); if (toggleButton(state && !iequals(state, "no"), "Toggle Tracks")) mpv->commandv("cycle-values", prop, "no", "auto", nullptr); + mpv_free(state); if (ImGui::BeginListBox("##tracks", ImVec2(-FLT_MIN, 3 * ImGui::GetTextLineHeightWithSpacing()))) { auto items = mpv->trackList(); if (items.empty()) ImGui::TextDisabled("");