[gnome-shell/gnome-3-24] layout: Range-check index before array lookup



commit 70f1f2d7be76f5a427a08d71237292c6546f26dc
Author: Florian Müllner <fmuellner gnome org>
Date:   Tue Jun 13 05:39:06 2017 +0200

    layout: Range-check index before array lookup
    
    findMonitorForActor() may be called before the layoutManager gets
    to initialize monitors, so make sure the monitor index is in range
    to avoid a warning.
    
    https://bugzilla.gnome.org/show_bug.cgi?id=781471

 js/ui/layout.js |    5 ++++-
 1 files changed, 4 insertions(+), 1 deletions(-)
---
diff --git a/js/ui/layout.js b/js/ui/layout.js
index aaf9da5..b1e7f94 100644
--- a/js/ui/layout.js
+++ b/js/ui/layout.js
@@ -896,7 +896,10 @@ const LayoutManager = new Lang.Class({
     },
 
     findMonitorForActor: function(actor) {
-        return this.monitors[this.findIndexForActor(actor)];
+        let index = this.findIndexForActor(actor);
+        if (index >= 0 && index < this.monitors.length)
+            return this.monitors[index];
+        return null;
     },
 
     _queueUpdateRegions: function() {


[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]