core: avoid out-of-bound reads in getColorFromPixel

fixes #92
This commit is contained in:
Vaxry 2024-10-24 23:50:35 +01:00
parent 185be7cd73
commit 17e1ebe9dc

View file

@ -457,6 +457,11 @@ void CHyprpicker::renderSurface(CLayerSurface* pSurface, bool forceInactive) {
} }
CColor CHyprpicker::getColorFromPixel(CLayerSurface* pLS, Vector2D pix) { 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; void* dataSrc = pLS->screenBuffer->paddedData ? pLS->screenBuffer->paddedData : pLS->screenBuffer->data;
struct pixel { struct pixel {
unsigned char blue; unsigned char blue;