Skip to content

Commit b1f2852

Browse files
committed
Make sure coords are in bounds.
1 parent 4a5572f commit b1f2852

File tree

1 file changed

+5
-0
lines changed

1 file changed

+5
-0
lines changed

src/robotjs.cc

+5
Original file line numberDiff line numberDiff line change
@@ -621,6 +621,11 @@ NAN_METHOD(getPixelColor)
621621
size_t x = info[0]->Int32Value();
622622
size_t y = info[1]->Int32Value();
623623

624+
if (!pointVisibleOnMainDisplay(MMPointMake(x, y)))
625+
{
626+
return Nan::ThrowError("Requested coordinates are outside the main screen's dimensions.");
627+
}
628+
624629
bitmap = copyMMBitmapFromDisplayInRect(MMRectMake(x, y, 1, 1));
625630

626631
color = MMRGBHexAtPoint(bitmap, 0, 0);

0 commit comments

Comments
 (0)