https://bugs.winehq.org/show_bug.cgi?id=55931
Bug ID: 55931 Summary: vbscript: empty MOD 100000 returns garbage instead of 0 Product: Wine Version: 8.20 Hardware: x86-64 OS: Linux Status: UNCONFIRMED Severity: normal Priority: P2 Component: vbscript Assignee: wine-bugs@winehq.org Reporter: jsm174@gmail.com Distribution: ---
While working on Visual Pinball scripting, we ran into a script where a high score gets loaded from a property file. If the file doesn't exist or the value isn't set, a variable contains empty. The variable is then MOD 10000 which sets a score reel.
On Windows, this will return 0:
Dim h_score : h_score = empty Dim temp : temp = h_score MOD 100000 WScript.echo "Temp " & temp
Output:
Temp 0
In Wine VBScript, temp will have a garbage value and thus drive the score reels with bad data.
Looking into
HRESULT WINAPI VarMod(LPVARIANT left, LPVARIANT right, LPVARIANT result)
case VT_CY : if(V_VT(left) == VT_EMPTY) { V_VT(result) = VT_I4;
rc = S_OK; goto end; }
result is never really initialized so this is where the garbage value comes from. I tested with V_I4(result) = 0 and was able to get 0.
I'm not sure if the best place to fix this is here or in interp_mod