From 1c85d9f2be17befa9cd18be99c56f8231b00bfef Mon Sep 17 00:00:00 2001 From: Mattias Gustavsson Date: Wed, 16 Sep 2020 13:58:09 +0200 Subject: [PATCH] SDA-2465 Clamping the display id to ensure we are not accessing outside the array --- src/app/window-handler.ts | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/src/app/window-handler.ts b/src/app/window-handler.ts index 3a975cc9..31c2ced0 100644 --- a/src/app/window-handler.ts +++ b/src/app/window-handler.ts @@ -803,10 +803,12 @@ export class WindowHandler { this.execCmd(this.screenShareIndicatorFrameUtil, [ source.display_id ]); } else { const dispId = source.id.split(':')[1]; + const clampedDispId = Math.min(dispId, displays.length - 1); const keyId = 'id'; logger.info('window-utils: dispId: ' + dispId); - logger.info('window-utils: displays [' + dispId + '] [id]: ' + displays [dispId] [ keyId ]); - this.execCmd(this.screenShareIndicatorFrameUtil, [ displays [dispId] [ keyId ].toString() ]); + logger.info('window-utils: clampedDispId: ' + clampedDispId); + logger.info('window-utils: displays [' + clampedDispId + '] [id]: ' + displays [clampedDispId] [ keyId ]); + this.execCmd(this.screenShareIndicatorFrameUtil, [ displays [clampedDispId] [ keyId ].toString() ]); } } }