How is this addon tainting?

#0 - Oct. 3, 2007, 11:26 a.m.
Blizzard Post
A small addon I wrote is frequently causing taint and I can't figure out how. It is an addon for displaying a timer on cooldown frames. If anyone can figure this out, I would really appreciate it. Here's the XML part:

<Script file="BaudActionTimer.lua"/>
<Frame name="BaudActionTimerTemplate" setAllPoints="true" virtual="true">
<Layers>
<Layer level="OVERLAY">
<FontString name="$parentTextLarge" inherits="MasterFont" font="Fonts\FRIZQT__.TTF">
<FontHeight><AbsValue val="15"/></FontHeight>
<Color r=".8" g=".8" b="0"/>
<Anchors><Anchor point="CENTER"/></Anchors>
</FontString>
<FontString name="$parentTextSmall" inherits="MasterFont" font="Fonts\FRIZQT__.TTF">
<FontHeight><AbsValue val="12"/></FontHeight>
<Color r=".8" g=".8" b="0"/>
<Anchors><Anchor point="CENTER"/></Anchors>
</FontString>
</Layer>
</Layers>
<Scripts>
<OnUpdate>
BaudActionTimer_OnUpdate();
</OnUpdate>
<OnSizeChanged>
BaudActionTimer_OnSizeChanged();
</OnSizeChanged>
</Scripts>
</Frame>


And here is the lua part:


hooksecurefunc("CooldownFrame_SetTimer",function(Cooldown, Start, Duration, Enable)
local Timer = getglobal(Cooldown:GetName().."Time");
if not Timer then
Timer = CreateFrame("Frame",Cooldown:GetName().."Time",Cooldown,"BaudActionTimerTemplate");
end
Timer.Start = Start;
Timer.Duration = Duration;
end);

function BaudActionTimer_OnSizeChanged()
this:SetScale(this:GetParent():GetWidth() / 36);
end

--Note that this will only show as long as the cooldown is shown
function BaudActionTimer_OnUpdate()
if not this.Duration then
return;
end
local Large, Small = getglobal(this:GetName().."TextLarge"), getglobal(this:GetName().."TextSmall");
local Remain = ceil(this.Duration-(GetTime()-this.Start)+1)-1;
if(this.Duration < 4)or(Remain < 0)then
if Large:IsShown()then
Large:Hide();
end
if Small:IsShown()then
Small:Hide();
end
return;
end
if(Remain >= 60)then
if Large:IsShown()then
Large:Hide();
end
Small:SetText(string.format("%d:%.2d",Remain / 60,Remain % 60));
if not Small:IsShown()then
Small:Show();
end
return;
end
if Small:IsShown()then
Small:Hide();
end
Large:SetText(Remain);
if not Large:IsShown()then
Large:Show();
end
#24 - Oct. 17, 2007, 4:27 a.m.
Blizzard Post
I'm looking into this, thanks!
#25 - Oct. 19, 2007, 12:20 a.m.
Blizzard Post
Yay, I figured this out!

The text status bar Lua code was assuming that it was being called in response to an event with arg1 and arg2, but it was being called to update frames in response to an event without any arg2. So, the arg2 value it was using was a left over tainted value from a previous event dispatch.

I'm refactoring the text status bar code a bit so it's more resilient to this kind of taint. This will be in the test realm update coming next week.
#28 - Oct. 20, 2007, 4:27 a.m.
Blizzard Post
This is fixed for next week's PTR update. In the meantime, please post followup here:
http://forums.worldofwarcraft.com/thread.html?topicId=2518903044&sid=1