From b1f28527767878524e64139cd53abdf60388f5a0 Mon Sep 17 00:00:00 2001 From: Jason Stallings Date: Fri, 8 Jan 2016 10:44:03 -0600 Subject: [PATCH] Make sure coords are in bounds. --- src/robotjs.cc | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/src/robotjs.cc b/src/robotjs.cc index 51b24fa3..f15cf4cb 100644 --- a/src/robotjs.cc +++ b/src/robotjs.cc @@ -621,6 +621,11 @@ NAN_METHOD(getPixelColor) size_t x = info[0]->Int32Value(); size_t y = info[1]->Int32Value(); + if (!pointVisibleOnMainDisplay(MMPointMake(x, y))) + { + return Nan::ThrowError("Requested coordinates are outside the main screen's dimensions."); + } + bitmap = copyMMBitmapFromDisplayInRect(MMRectMake(x, y, 1, 1)); color = MMRGBHexAtPoint(bitmap, 0, 0);