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:
committed by
waddlesplash
parent
1e0308a84d
commit
7b3d134fae
@@ -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
|
||||
|
||||
|
||||
Reference in New Issue
Block a user