Advertisement:
NameCheap

Author Topic: SMF 2.0.2 "Stack overflow at line 1322"  (Read 1606 times)

Offline willyvmm

  • Newbie
  • *
  • Posts: 2
SMF 2.0.2 "Stack overflow at line 1322"
« on: January 31, 2012, 04:27:35 PM »
Thereis a Bug in script.js. The bug exist on ALL  platforms, but only IE8 on XP platform shows that if you are not logged in. Other browsers just ignore that.

Code: (JavaScript) [Select]
function addLoadEvent(fNewOnload)
{
// If there's no event set, just set this one
if (typeof(fNewOnload) == 'function' && (!('onload' in window) || typeof(window.onload) != 'function'))
window.onload = fNewOnload;

// If there's just one event, setup the array.
else if (aOnloadEvents.length == 0)
{
aOnloadEvents[0] = window.onload;
aOnloadEvents[1] = fNewOnload;
window.onload = function() {
for (var i = 0, n = aOnloadEvents.length; i < n; i++)
{
if (typeof(aOnloadEvents[i]) == 'function')
aOnloadEvents[i]();           
else if (typeof(aOnloadEvents[i]) == 'string')
eval(aOnloadEvents[i]);
}
}
}

// This isn't the first event function, add it to the list.
else
aOnloadEvents[aOnloadEvents.length] = fNewOnload;
}

In this function The array aOnloadEvents is defined, and the first
  • element of that array, point on the function that works in this case as a recursive function.

It results as infinity recursive loop ...
The fix is Easy:

Just commnet out line 1316: (or remove);
Code: (JavaScript) [Select]
aOnloadEvents[0] = window.onload;
And change index from 1 to 0 in the next line (1317):
Code: (JavaScript) [Select]
aOnloadEvents[1] = fNewOnload;
after change:
Code: (JavaScript) [Select]
// aOnloadEvents[0] = window.onload;
aOnloadEvents[0] = fNewOnload;

I'am not shure if the script lost some of its functionality but I hope it is still working as it should.

Best Regards Willy.


I've just found that is not the best solution ... and the error ocurs only if the function was called 2nd time with empty aOnloadEvents array.
« Last Edit: January 31, 2012, 04:45:51 PM by willyvmm »

Offline willyvmm

  • Newbie
  • *
  • Posts: 2
Re: SMF 2.0.2 "Stack overflow at line 1322"
« Reply #1 on: January 31, 2012, 05:29:31 PM »
I've investigated this problem little bit more. This is not SMF bug, this is Jfusion(joomla integration) bug.

Offline emanuele

  • SMF Super Hero
  • *******
  • Posts: 14,161
  • Gender: Male
  • THERE'S JUST ME
Re: SMF 2.0.2 "Stack overflow at line 1322"
« Reply #2 on: January 31, 2012, 05:52:19 PM »
Thanks for taking time to report and look into it!


Take a peek at what I'm doing! ;D



Hai bisogno di supporto in Italiano?

Aiutateci ad aiutarvi: spiegate bene il vostro problema: no, "non funziona" non รจ una spiegazione!!
1) Cosa fai,
2) cosa ti aspetti,
3) cosa ottieni.