[PATCH 2/9] jscript: Handle NULL objects instead of crashing.

Jacek Caban jacek at codeweavers.com
Tue Mar 22 11:36:37 CDT 2022


Hi Gabriel,

On 3/22/22 16:41, Gabriel Ivăncescu wrote:
> Signed-off-by: Gabriel Ivăncescu<gabrielopcode at gmail.com>
> ---
>
> Most of the existing code deals with NULL objects already and has proper
> checks, but some does not. Not only is this inconsistent, but it makes no
> sense to crash. For example, FFXIV Launcher uses instanceof on a NULL obj,
> but there's many other areas that need handling as well. This should fix
> them all, hopefully.
>
>   dlls/jscript/array.c      |  8 ++++----
>   dlls/jscript/bool.c       |  2 +-
>   dlls/jscript/date.c       |  2 +-
>   dlls/jscript/dispex.c     |  2 +-
>   dlls/jscript/engine.c     | 10 +++++-----
>   dlls/jscript/enumerator.c |  4 ++--
>   dlls/jscript/error.c      |  2 +-
>   dlls/jscript/function.c   |  8 ++++----
>   dlls/jscript/json.c       |  2 +-
>   dlls/jscript/jsregexp.c   |  6 +++---
>   dlls/jscript/jsutils.c    |  4 ++--
>   dlls/jscript/number.c     |  2 +-
>   dlls/jscript/object.c     | 18 +++++++++---------
>   dlls/jscript/set.c        |  2 +-
>   dlls/jscript/string.c     | 12 ++++++------
>   dlls/jscript/vbarray.c    |  2 +-
>   16 files changed, 43 insertions(+), 43 deletions(-)


This really could use some tests. You can grep for nullDisp for examples 
of such tests.


In general, I'm hoping that we could have a better solution. See the 
attached patch for a draft of possible solution that stores NULL 
VT_DISPATCH as JS null, which seems to match how we should treat it in 
majority cases. On top of that, we could get rid of all those NULL 
checks. It passes current tests, but more tests would be interesting.


Thanks,

Jacek
-------------- next part --------------
A non-text attachment was scrubbed...
Name: patch.diff
Type: text/x-patch
Size: 3793 bytes
Desc: not available
URL: <http://www.winehq.org/pipermail/wine-devel/attachments/20220322/27a4bf7e/attachment.bin>


More information about the wine-devel mailing list