mirror of
https://github.com/hyprwm/Hyprland
synced 2026-05-07 14:18:30 +02:00
format: safeguard drmGetFormat functions (#13416)
they can return null if not found.
This commit is contained in:
parent
74c087ca9b
commit
c2ba7fc9c4
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
Reference in a new issue