Screen preflet: fix possible NULL pointer dereference

Change-Id: Ia343cb2cba23f02d5504dfb849a059f041138119
Reviewed-on: https://review.haiku-os.org/c/haiku/+/5571
Reviewed-by: waddlesplash <[email protected]>
This commit is contained in:
JackBurton79
2022-08-25 21:10:15 +00:00
committed by waddlesplash
parent 1e0308a84d
commit 7b3d134fae
+5 -1
View File
@@ -382,6 +382,8 @@ ScreenMode::GetManufacturerFromID(const char* id) const
const size_t numElements = sizeof(kPNPIDs) / sizeof(kPNPIDs[0]);
const struct pnp_id key = { id, "dummy" };
const pnp_id* element = std::find(kPNPIDs, kPNPIDs + numElements, key);
if (element == NULL)
return NULL;
return element->manufacturer;
}
@@ -411,7 +413,9 @@ ScreenMode::GetMonitorInfo(monitor_info& info, float* _diagonalInches)
char vendor[4];
strlcpy(vendor, info.vendor, sizeof(vendor));
strlcpy(info.vendor, GetManufacturerFromID(vendor), sizeof(info.vendor));
const char* vendorString = GetManufacturerFromID(vendor);
if (vendorString != NULL)
strlcpy(info.vendor, vendorString, sizeof(info.vendor));
// Remove extraneous vendor strings and whitespace