From dcc6a9b449ccb393297845b49d86ee7ba087f29d Mon Sep 17 00:00:00 2001 From: RickDB Date: Tue, 15 Mar 2016 11:45:25 +0100 Subject: [PATCH] Make sure the byte array is empty before filling it. Former-commit-id: 64f76fa358234e131377ecfabf196f3c7324e79f --- libsrc/leddevice/LedDeviceAtmoOrb.cpp | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/libsrc/leddevice/LedDeviceAtmoOrb.cpp b/libsrc/leddevice/LedDeviceAtmoOrb.cpp index 032d566f..62382ddf 100644 --- a/libsrc/leddevice/LedDeviceAtmoOrb.cpp +++ b/libsrc/leddevice/LedDeviceAtmoOrb.cpp @@ -76,7 +76,8 @@ int LedDeviceAtmoOrb::write(const std::vector & ledValues) { void LedDeviceAtmoOrb::setColor(unsigned int orbId, const ColorRgb& color, int commandType) { QByteArray bytes; - bytes.resize(5 + numLeds * 3); + bytes.resize(5 + numLeds * 3); + bytes.fill('\0'); // Command identifier: C0FFEE bytes[0] = 0xC0; @@ -106,7 +107,8 @@ void LedDeviceAtmoOrb::sendCommand(const QByteArray & bytes) { int LedDeviceAtmoOrb::switchOff() { for (unsigned int i = 0; i < orbIds.size(); i++) { QByteArray bytes; - bytes.resize(5 + numLeds * 3); + bytes.resize(5 + numLeds * 3); + bytes.fill('\0'); // Command identifier: C0FFEE bytes[0] = 0xC0;