From 17e1ebe9dcb4157f1d3866f55d7fe55f20d979d0 Mon Sep 17 00:00:00 2001 From: Vaxry Date: Thu, 24 Oct 2024 23:50:35 +0100 Subject: [PATCH] core: avoid out-of-bound reads in getColorFromPixel fixes #92 --- src/hyprpicker.cpp | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/src/hyprpicker.cpp b/src/hyprpicker.cpp index 6df5ef1..b694f1d 100644 --- a/src/hyprpicker.cpp +++ b/src/hyprpicker.cpp @@ -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;