Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix interpreter crash #794

Merged
merged 3 commits into from
Nov 13, 2023

Conversation

christoph-heinrich
Copy link
Contributor

@christoph-heinrich christoph-heinrich commented Nov 13, 2023

The crash happens because utils.parse_json(json_string) returns table, nil, '', which then get passed as varargs to table_assign(), which doesn't like that string as argument.

I don't know if we should fix the crash by checking that the type is a table, because technically anything other then a table is a violation of defined argument types of the function and therefore it might be preferable the fix the call site (intl.lua:59 and intl.lua:63) instead?

Fixes crash from #792

The # operator produces different results on luajit to the
interpreter for lists like `{1, nil, 3}`.
The interpreter gives a size of 3, while luajit says it's 1.

That caused `table_assign` and `itable_join` to behave differently depending
on the lua environment they're running in.

To get the total number of vararg arguments, `select('#', ...)`` can be
used, which doesn't stop counting when it encounters `nil`.
@tomasklaen
Copy link
Owner

tomasklaen commented Nov 13, 2023

The (i)table functions fix is fine and should stay, but we should also make get_locale_from_json() return only a single value: parsed table, or nil when anything failed.

@tomasklaen tomasklaen merged commit 210a121 into tomasklaen:main Nov 13, 2023
@christoph-heinrich christoph-heinrich deleted the fix_interpreter_crash branch November 13, 2023 18:00
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants