Skip to content

Commit 3fcb6b4

Browse files
committed
Fix regression in ArcticController
Using sizeof() on a pointer yields the size of the pointer variable, not the size of the referenced variable. Signed-off-by: Armin Wolf <W_Armin@gmx.de>
1 parent 2eb5699 commit 3fcb6b4

1 file changed

Lines changed: 3 additions & 2 deletions

File tree

Controllers/ArcticController/ArcticController.cpp

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -68,7 +68,8 @@ static void FormatCommandBuffer(char *buffer, char command)
6868

6969
void ArcticController::SetChannels(std::vector<RGBColor> colors)
7070
{
71-
char* buffer = new char[ARCTIC_COMMAND_BUFFER_LENGTH(colors.size() * 3)];
71+
size_t buffer_length = ARCTIC_COMMAND_BUFFER_LENGTH(colors.size() * 3);
72+
char* buffer = new char[buffer_length];
7273

7374
FormatCommandBuffer(buffer, ARCTIC_COMMAND_SET_RGB);
7475

@@ -81,7 +82,7 @@ void ArcticController::SetChannels(std::vector<RGBColor> colors)
8182
buffer[offset + 0x02] = (char)std::min<unsigned int>(254, RGBGetBValue(colors[channel]));
8283
}
8384

84-
serialport.serial_write(buffer, sizeof(buffer));
85+
serialport.serial_write(buffer, buffer_length);
8586

8687
delete[] buffer;
8788
}

0 commit comments

Comments
 (0)