Ticket #754 (closed defect: invalid)

Opened 3 years ago

Last modified 3 years ago

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++) {

Change History

Changed 3 years ago by EricShulman

hmm... upon further consideration, I'm not sure that adding 'var' to those loops will actually fix the problem, given that that initial use of 'var i' in the first loop should have made the variable locally-scoped already.

Changed 3 years ago by FND

  • milestone set to 2.5

Changed 3 years ago by FND

  • status changed from new to closed
  • resolution set to invalid

It appears there is no globally-scoped i variable.

Changed 3 years ago by MartinBudden

  • milestone changed from 2.5 to 2.4.2
Note: See TracTickets for help on using tickets.