From 2a3ff6a61de1f168df21a123739bfbccfb757fcf Mon Sep 17 00:00:00 2001 From: Tom Englund Date: Fri, 5 Jul 2024 15:18:44 +0200 Subject: [PATCH] formatutils: ensure we dont leak name ptr (#2) store format name in a std::string and free the char ptr to ensure we dont leak on each call to drmGetFormatName. --- src/utils/FormatUtils.cpp | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/src/utils/FormatUtils.cpp b/src/utils/FormatUtils.cpp index e091505..90c5d1f 100644 --- a/src/utils/FormatUtils.cpp +++ b/src/utils/FormatUtils.cpp @@ -3,6 +3,8 @@ #include std::string fourccToName(uint32_t drmFormat) { - auto fmt = drmGetFormatName(drmFormat); - return fmt ? fmt : "unknown"; + auto fmt = drmGetFormatName(drmFormat); + std::string name = fmt ? fmt : "unknown"; + free(fmt); + return name; }