From ce8f05de1849979d0bfbc758232601f0a51a6315 Mon Sep 17 00:00:00 2001 From: Paulo Scardine Date: Sun, 9 Jun 2013 23:16:26 -0300 Subject: [PATCH] Fix race condition (TypeError: Cannot call method 'get' of undefined) Sometimes a listener may be removed between the call `length = watchers.length;` on line 517 and `watch = watchers[length];`; in this case, `watch` will be undefined and the call to `watch.get` at line 523 will fail. --- src/ng/rootScope.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/ng/rootScope.js b/src/ng/rootScope.js index 6648655133f1..0d9e9078f032 100644 --- a/src/ng/rootScope.js +++ b/src/ng/rootScope.js @@ -520,7 +520,7 @@ function $RootScopeProvider(){ watch = watchers[length]; // Most common watches are on primitives, in which case we can short // circuit it with === operator, only when === fails do we use .equals - if ((value = watch.get(current)) !== (last = watch.last) && + if (watch && (value = watch.get(current)) !== (last = watch.last) && !(watch.eq ? equals(value, last) : (typeof value == 'number' && typeof last == 'number'