format: safeguard drmGetFormat functions (#13416)
they can return null if not found.
This commit is contained in:
parent
362ea7b0f3
commit
d2b9957fab
1 changed files with 10 additions and 2 deletions
|
|
@ -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;
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue