Ticket #754 (closed defect: invalid)
eliminate global loop indices from loadPlugins() function
| Reported by: | EricShulman | Owned by: | JeremyRuston |
|---|---|---|---|
| Priority: | major | Milestone: | 2.4.2 |
| Component: | core | Version: | |
| Severity: | high | Keywords: | |
| Cc: |
Description
The loadPlugins() function performs several loops during startup, using a loop index variable, "i", normally declared as a local variable using this syntax:
for (var i=0;... )
However, some of the loops within loadPlugins() have omitted the 'var' from the loop declaration, specifically:
for(i=0; i<nPlugins; i++) AND for(i=0; i<toLoad.length; i++)
As a result, the index variable, "i", is *globally-scoped* while loadPlugins() is processing those loops.
This creates a serious *browser-hang* problem if a plugin, during initialization, also make globally-scoped references to a variable named "i". Assigning to that variable steps on the current index value in the outer controlling loop in loadPlugins(), which can result either A) some plugins not being loaded, or B) an infinite loop as the same plugins are loaded over and over again.
To fix this problem, simply add the 'var' keyword to the loop declarations within loadPlugins(), like this:
for(var i=0; i<nPlugins; i++)
AND
for(var i=0; i<toLoad.length; i++) {
