Bounds checking for ResizeZone implementations
As noted in #350, various RGBControllers don't validate if the zone they are trying to resize actually exists. This was fixed by a just checking they remain in bounds.
This commit is contained in:
parent
bb743c6b62
commit
ecf1d2ce98
6 changed files with 31 additions and 1 deletions
|
|
@ -175,6 +175,11 @@ void RGBController_AuraUSB::SetupZones()
|
|||
|
||||
void RGBController_AuraUSB::ResizeZone(int zone, int new_size)
|
||||
{
|
||||
if((size_t) zone >= zones.size())
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
if(((unsigned int)new_size >= zones[zone].leds_min) && ((unsigned int)new_size <= zones[zone].leds_max))
|
||||
{
|
||||
zones[zone].leds_count = new_size;
|
||||
|
|
|
|||
|
|
@ -231,6 +231,11 @@ void RGBController_CorsairLightingNode::SetupZones()
|
|||
|
||||
void RGBController_CorsairLightingNode::ResizeZone(int zone, int new_size)
|
||||
{
|
||||
if((size_t) zone >= zones.size())
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
if(((unsigned int)new_size >= zones[zone].leds_min) && ((unsigned int)new_size <= zones[zone].leds_max))
|
||||
{
|
||||
zones[zone].leds_count = new_size;
|
||||
|
|
|
|||
|
|
@ -220,6 +220,11 @@ void RGBController_HuePlus::SetupZones()
|
|||
|
||||
void RGBController_HuePlus::ResizeZone(int zone, int new_size)
|
||||
{
|
||||
if((size_t) zone >= zones.size())
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
if(((unsigned int)new_size >= zones[zone].leds_min) && ((unsigned int)new_size <= zones[zone].leds_max))
|
||||
{
|
||||
zones[zone].leds_count = new_size;
|
||||
|
|
|
|||
|
|
@ -93,6 +93,11 @@ void RGBController_MSIMysticLight::SetupZones()
|
|||
|
||||
void RGBController_MSIMysticLight::ResizeZone(int zone, int new_size)
|
||||
{
|
||||
if((size_t) zone >= zones.size())
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
MSI_ZONE zon = ZoneFromPos(zone);
|
||||
unsigned int max_count = controller->GetZoneMaxLedCount(zon);
|
||||
unsigned int min_count = controller->GetZoneMinLedCount(zon);
|
||||
|
|
@ -222,4 +227,4 @@ void RGBController_MSIMysticLight::SetupMode(const char *name, MSI_MODE mod, uns
|
|||
}
|
||||
|
||||
modes.push_back(Mode);
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -284,6 +284,11 @@ void RGBController_RGBFusion2USB::SetupZones()
|
|||
|
||||
void RGBController_RGBFusion2USB::ResizeZone(int zone, int new_size)
|
||||
{
|
||||
if((size_t) zone >= zones.size())
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
if(((unsigned int)new_size >= zones[zone].leds_min) && ((unsigned int)new_size <= zones[zone].leds_max))
|
||||
{
|
||||
zones[zone].leds_count = new_size;
|
||||
|
|
|
|||
|
|
@ -170,6 +170,11 @@ void RGBController_ThermaltakeRiing::SetupZones()
|
|||
|
||||
void RGBController_ThermaltakeRiing::ResizeZone(int zone, int new_size)
|
||||
{
|
||||
if((size_t) zone >= zones.size())
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
if(((unsigned int)new_size >= zones[zone].leds_min) && ((unsigned int)new_size <= zones[zone].leds_max))
|
||||
{
|
||||
zones[zone].leds_count = new_size;
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue