Skip to content
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -221,9 +221,21 @@ void RGBController_Razer::SetupZones()
new_kb.ChangeKeys(*temp);

/*---------------------------------------------------------*\
| Matrix map still uses declared zone rows and columns |
| as the packet structure depends on the matrix map |
| KLM overlay insertions can expand the key grid beyond the |
| declared zone dimensions. Reallocate the map buffer to |
| the actual KLM dimensions to prevent a heap overflow. |
| new_map height/width stay at declared values so the HID |
| packet structure (which depends on them) is unchanged. |
\*---------------------------------------------------------*/
unsigned int map_height = std::max((unsigned int)new_map->height, new_kb.GetRowCount());
unsigned int map_width = std::max((unsigned int)new_map->width, new_kb.GetColumnCount());

if(map_height * map_width > (unsigned int)new_map->height * new_map->width)
{
delete[] new_map->map;
new_map->map = new unsigned int[map_height * map_width];
}

new_kb.GetKeyMap(new_map->map, KEYBOARD_MAP_FILL_TYPE_INDEX, new_map->height, new_map->width);
}

Expand Down