format: safeguard drmGetFormat functions (#13416)

they can return null if not found.
This commit is contained in:
Tom Englund 2026-02-28 16:29:22 +01:00 committed by GitHub
parent 362ea7b0f3
commit d2b9957fab
No known key found for this signature in database
GPG key ID: B5690EEEBB952194

View file

@ -314,14 +314,22 @@ uint32_t NFormatUtils::glFormatToType(uint32_t gl) {
}
std::string NFormatUtils::drmFormatName(DRMFormat drm) {
auto n = drmGetFormatName(drm);
auto n = drmGetFormatName(drm);
if (!n)
return "unknown";
std::string name = n;
free(n); // NOLINT(cppcoreguidelines-no-malloc,-warnings-as-errors)
return name;
}
std::string NFormatUtils::drmModifierName(uint64_t mod) {
auto n = drmGetFormatModifierName(mod);
auto n = drmGetFormatModifierName(mod);
if (!n)
return "unknown";
std::string name = n;
free(n); // NOLINT(cppcoreguidelines-no-malloc,-warnings-as-errors)
return name;