[tbb-commits] [torbutton/master] Bug 13891: Avoid undefined circuitStatuses/bridges

gk at torproject.org gk at torproject.org
Thu Mar 12 11:09:32 UTC 2015


commit bf2ee7eddab0eaed16ea6825ab084a6a183054f6
Author: Arthur Edelstein <arthuredelstein at gmail.com>
Date:   Tue Mar 10 16:08:55 2015 -0700

    Bug 13891: Avoid undefined circuitStatuses/bridges
---
 src/chrome/content/tor-circuit-display.js |   17 +++++++++++------
 1 file changed, 11 insertions(+), 6 deletions(-)

diff --git a/src/chrome/content/tor-circuit-display.js b/src/chrome/content/tor-circuit-display.js
index b31953d..a4ba919 100644
--- a/src/chrome/content/tor-circuit-display.js
+++ b/src/chrome/content/tor-circuit-display.js
@@ -54,9 +54,11 @@ let trimQuotes = s => s ? s.match(/^\"(.*)\"$/)[1] : undefined;
 // is not currently used as a bridge, returns null.
 let getBridge = function* (controller, id) {
   let bridges = yield controller.getConf("bridge");
-  for (let bridge of bridges) {
-    if (bridge.ID && bridge.ID.toUpperCase() === id.toUpperCase()) {
-      return bridge;
+  if (bridges) {
+    for (let bridge of bridges) {
+      if (bridge.ID && bridge.ID.toUpperCase() === id.toUpperCase()) {
+        return bridge;
+      }
     }
   }
   return null;
@@ -107,11 +109,14 @@ let nodeDataForCircuit = function* (controller, circuitEvent) {
 // Returns the circuit status for the circuit with the given ID.
 let getCircuitStatusByID = function* (aController, circuitID) {
   let circuitStatuses = yield aController.getInfo("circuit-status");
-  for (let circuitStatus of circuitStatuses) {
-    if (circuitStatus.id === circuitID) {
-      return circuitStatus;
+  if (circuitStatuses) {
+    for (let circuitStatus of circuitStatuses) {
+      if (circuitStatus.id === circuitID) {
+        return circuitStatus;
+      }
     }
   }
+  return null;
 };
 
 // __collectIsolationData(aController)__.



More information about the tbb-commits mailing list