Permalink
Browse files

add cast to unsigned in getPixelColor() to prevent overflow

  • Loading branch information...
1 parent 2a058b0 commit d2219430a5ae8cb2ffea63aed9be1ecc68f6ee4f @AntonKast AntonKast committed Aug 10, 2012
Showing with 1 addition and 1 deletion.
  1. +1 −1 Adafruit_WS2801.cpp
View
@@ -187,7 +187,7 @@ uint32_t Adafruit_WS2801::getPixelColor(uint16_t n) {
// types. For compatibility with existing code, 'packed' RGB
// values passed in or out are always 0xRRGGBB order.
return (rgb_order == WS2801_RGB) ?
- ((uint32_t)pixels[ofs] << 16) | (pixels[ofs + 1] << 8) | pixels[ofs + 2] :
+ ((uint32_t)pixels[ofs] << 16) | ((uint16_t) pixels[ofs + 1] << 8) | pixels[ofs + 2] :
(pixels[ofs] << 8) | ((uint32_t)pixels[ofs + 1] << 16) | pixels[ofs + 2];
}

0 comments on commit d221943

Please sign in to comment.