Skip to content

Commit

Permalink
core: avoid out-of-bound reads in getColorFromPixel
Browse files Browse the repository at this point in the history
fixes #92
  • Loading branch information
vaxerski committed Oct 24, 2024
1 parent 185be7c commit 17e1ebe
Showing 1 changed file with 5 additions and 0 deletions.
5 changes: 5 additions & 0 deletions src/hyprpicker.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -457,6 +457,11 @@ void CHyprpicker::renderSurface(CLayerSurface* pSurface, bool forceInactive) {
}

CColor CHyprpicker::getColorFromPixel(CLayerSurface* pLS, Vector2D pix) {
pix = pix.floor();

if (pix.x >= pLS->screenBuffer->pixelSize.x || pix.y >= pLS->screenBuffer->pixelSize.y)
return CColor{0, 0, 0, 0};

void* dataSrc = pLS->screenBuffer->paddedData ? pLS->screenBuffer->paddedData : pLS->screenBuffer->data;
struct pixel {
unsigned char blue;
Expand Down

0 comments on commit 17e1ebe

Please sign in to comment.