Skip to content

Commit

Permalink
formatutils: ensure we dont leak name ptr (#2)
Browse files Browse the repository at this point in the history
store format name in a std::string and free the char ptr to ensure we
dont leak on each call to drmGetFormatName.
  • Loading branch information
gulafaran authored Jul 5, 2024
1 parent c5cf93a commit 2a3ff6a
Showing 1 changed file with 4 additions and 2 deletions.
6 changes: 4 additions & 2 deletions src/utils/FormatUtils.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,8 @@
#include <xf86drm.h>

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;
}

0 comments on commit 2a3ff6a

Please sign in to comment.