Fix for ONOS-5403

Change-Id: I8b20ad7752e4a11e6bae1130f1649fed3335c7ed
diff --git a/web/gui/src/main/webapp/app/view/topo/topoLink.js b/web/gui/src/main/webapp/app/view/topo/topoLink.js
index bfe0df5..708ff91 100644
--- a/web/gui/src/main/webapp/app/view/topo/topoLink.js
+++ b/web/gui/src/main/webapp/app/view/topo/topoLink.js
@@ -121,10 +121,13 @@
                     return; // skip hidden host links
                 }
 
-                var line = d.position,
+                if(d.position != null)
+                {
+                    var line = d.position,
                     point = pdrop(line, mouse),
                     hit = lineHit(line, point, mouse),
                     dist;
+                }
 
                 if (hit) {
                     dist = mdist(point, mouse);
@@ -222,13 +225,18 @@
 
          tss.deselectAll();
 
-         if (!ldata.el.classed('selected')) {
-            selLink(ldata);
-            return;
-         }
+         if(ldata != null)
+         {
 
-         if (ldata.el.classed('selected')) {
-            unselLink(ldata);
+            if (!ldata.el.classed('selected')) {
+                selLink(ldata);
+                return;
+            }
+
+            if (ldata.el.classed('selected')) {
+                unselLink(ldata);
+                return;
+            }
          }
     }
 
diff --git a/web/gui/src/main/webapp/app/view/topo/topoSelect.js b/web/gui/src/main/webapp/app/view/topo/topoSelect.js
index 1cd211b..bdcf244 100644
--- a/web/gui/src/main/webapp/app/view/topo/topoSelect.js
+++ b/web/gui/src/main/webapp/app/view/topo/topoSelect.js
@@ -107,17 +107,18 @@
             });
         }
 
-        if (obj.class === 'link') {
-
-            if (selections[obj.key]) {
-                deselectObject(obj.key);
-            } else {
-                selections[obj.key] = { obj: obj, el: el };
-                selectOrder.push(obj.key);
+        if (obj !=null)
+        {
+            if (obj.class === 'link') {
+                if (selections[obj.key]) {
+                    deselectObject(obj.key);
+                } else {
+                    selections[obj.key] = { obj: obj, el: el };
+                    selectOrder.push(obj.key);
+                }
+                updateDetail();
+                return;
             }
-
-            updateDetail();
-            return;
         }
 
         if (!n) {