angular/angular.js — pull request #2915 by scardine (2013-06-10 02:37:21+00:00)
Title: Fix for race condition bug in the "traverse the scopes" loop.

Calls to Scope.$watch returns a deregistration function for this listener.

Sometimes a listener may be removed by this function between the call `length = watchers.length;` on line 517 and `watch = watchers[length];` on line 520; in this case, `watch` will be undefined and the call to `watch.get` at line 523 will fail.

This is a real bug and I was bitten when writing a huge directive (using d3.js). The case must be obvious enough and the fix is too small to bother creating a reproducible test case - testing for the existence of `watch` before calling `watch.get` will not hurt, anyway.