https://bugs.winehq.org/show_bug.cgi?id=39892
--- Comment #12 from Anthony Fok anthony@anthonyfok.org --- Created attachment 53280 --> https://bugs.winehq.org/attachment.cgi?id=53280 Prevent type mismatch error with getAttribute("onclick", 2)
It appears that UFile tries to do this:
getAttribute("onclick", 2);
However, HTMLElement_get_onclick() somehow gives back an AttributeValue of VT_NULL, which of course fails to be converted to VT_BSTR, thus VariantChangeType() returns a HRESULT of 0x80020005 (Type Mismatch), which HTMLElement_getAttribute() also returns, leading to the runtime error and crash.
In Wine 1.7.32, HTMLElement_getAttribute() did not do any VariantChangeType(), and happily returns S_OK as the HRESULT, so UFile kept on running happily without crashing.
So, the attached patch adds a test case for VT_NULL and change it to a VT_BSTR(NULL) and returns S_OK, reverting to the behaviour in Wine 1.7.32. No more crashing. Yay!
However, I do suspect the real problem lies with HTMLElement_get_onclick() and other JScript-related HTMLElement_get_xxxxxx() functions. Shouldn't it be able to return an AttributeValue as a string (i.e., BSTR)? How did it become VT_NULL?