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
https://bugs.winehq.org/show_bug.cgi?id=55931
francisdb francisdb@gmail.com changed:
What |Removed |Added ---------------------------------------------------------------------------- CC| |francisdb@gmail.com
https://bugs.winehq.org/show_bug.cgi?id=55931
--- Comment #1 from Nikolay Sivov bunglehead@gmail.com --- Created attachment 75498 --> https://bugs.winehq.org/attachment.cgi?id=75498 test patch
This looks like VarMod() bug to me, so the fix belongs to oleaut32. Our current tests hide this problem, see attached diff.
https://bugs.winehq.org/show_bug.cgi?id=55931
--- Comment #2 from Jason Millard jsm174@gmail.com --- ahh, the memset is clearing out in the tests.
Would the correct fix be doing a memset or adding a VariantInit
``` HRESULT WINAPI VarMod(LPVARIANT left, LPVARIANT right, LPVARIANT result) { HRESULT rc = E_FAIL; int resT = 0; VARIANT lv,rv; VARIANT tempLeft, tempRight;
VariantInit(result); VariantInit(&tempLeft); VariantInit(&tempRight); VariantInit(&lv); VariantInit(&rv); ```
https://bugs.winehq.org/show_bug.cgi?id=55931
--- Comment #3 from Nikolay Sivov bunglehead@gmail.com --- It depends on how it works, we are not testing that initial value is preserved or not.
https://bugs.winehq.org/show_bug.cgi?id=55931
--- Comment #4 from Jason Millard jsm174@gmail.com --- (In reply to Nikolay Sivov from comment #3)
It depends on how it works, we are not testing that initial value is preserved or not.
Okay, I just tested this:
Dim h_score : h_score = empty Dim temp : temp = 5 temp = h_score MOD 100000 WScript.echo "Temp " & temp
This still outputs
Temp 0
https://bugs.winehq.org/show_bug.cgi?id=55931
--- Comment #5 from Nikolay Sivov bunglehead@gmail.com --- Testing should be done with just VarMod(), we'll see if something is not right still at vbscript once main thing is fixed.
https://bugs.winehq.org/show_bug.cgi?id=55931
--- Comment #6 from Jason Millard jsm174@gmail.com --- Okay, makes sense.
At this time, I don't have an easy way to quickly test VarMod, but I will look into it.
https://bugs.winehq.org/show_bug.cgi?id=55931
Robert Wilhelm sloper42@yahoo.com changed:
What |Removed |Added ---------------------------------------------------------------------------- Ever confirmed|0 |1 CC| |sloper42@yahoo.com Status|UNCONFIRMED |NEW
--- Comment #7 from Robert Wilhelm sloper42@yahoo.com --- confirming
https://bugs.winehq.org/show_bug.cgi?id=55931
Nikolay Sivov bunglehead@gmail.com changed:
What |Removed |Added ---------------------------------------------------------------------------- Component|vbscript |oleaut32
--- Comment #8 from Nikolay Sivov bunglehead@gmail.com --- https://gitlab.winehq.org/wine/wine/-/merge_requests/4515
https://bugs.winehq.org/show_bug.cgi?id=55931
Nikolay Sivov bunglehead@gmail.com changed:
What |Removed |Added ---------------------------------------------------------------------------- Summary|vbscript: empty MOD 100000 |VarMod(Empty, N) returns |returns garbage instead of |uninitialized result |0 |
https://bugs.winehq.org/show_bug.cgi?id=55931
Nikolay Sivov bunglehead@gmail.com changed:
What |Removed |Added ---------------------------------------------------------------------------- Status|NEW |RESOLVED Resolution|--- |FIXED Fixed by SHA1| |bda6decd473f0dd5a32ed6fe4a6 | |cc55ab7a14bad
--- Comment #9 from Nikolay Sivov bunglehead@gmail.com --- Marking fixed, https://source.winehq.org/git/wine.git/commit/bda6decd473f0dd5a32ed6fe4a6cc5....
https://bugs.winehq.org/show_bug.cgi?id=55931
--- Comment #10 from Jason Millard jsm174@gmail.com --- Fantastic. Much appreciated!!
https://bugs.winehq.org/show_bug.cgi?id=55931
Alexandre Julliard julliard@winehq.org changed:
What |Removed |Added ---------------------------------------------------------------------------- Status|RESOLVED |CLOSED
--- Comment #11 from Alexandre Julliard julliard@winehq.org --- Closing bugs fixed in 9.0-rc1.