2 bugs in the Virtual Earth API
01 Mar 2007
It's not everyday that you find a bug in a piece of Microsoft code, but 2
bugs in one day? And those 2 bugs being in the same function? Well I should have
played the lottery this week.
In the Virtual Earth API the VEPushpin.Dipose
function contains 2 bugs, which are caused through carelessness more than anything
else (we all make them).
The LOC is:
VEPushpin.prototype.Dispose=function(){this.DetailsStyle==null; this.TitleStyle=null;this.IconStyle=null;this.Details=null;this.IconUrl=null;this.Title=null;this.LatLong=null;this.ID=null;this.m_vemapcontrol=null;this.m_vemap=null
Taking a quick glance and only one is obvious.
Instead of setting the this.DetailsStyle variable to null, a boolean comparison
is being performed. When the method is meant to set everything to null what you don't
expect is somethings to not be nulled.
The second bug is this.IconUrl. Now this could be '100% correct' within this
function as it has the naming convention of the Virtual Earth API. But when the rest
of the VEPusphin object appears to use Iconurl as the variable then its a bug. Iconurl
doesn't get nulled, and a new object variable gets created called IconUrl and set
to null. I love javascripts strong
typing (or lack of).
Still after finding these bugs and creating my a workaround fix it hasn't fixed the
memory leak that's occuring.