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 janet_formatbv() type when handling %d %u int specifiers #1167

Merged
merged 1 commit into from
May 29, 2023

Conversation

zevv
Copy link
Contributor

@zevv zevv commented May 29, 2023

At https://github.com/janet-lang/janet/blob/master/src/core/pp.c#L849, janet_formatbv() pulls a long instead of an int when handling the %d specifier, potentially leading to wrong results:

janet_eprintf(">>> %d\n", (int32_t) - 1);

output:

>>> 4294967295

In the wild this shows like this:

(buffer/slice @"" 3)                                                  

error thrown:

error: start index 3 out of range [4294967295,0]

The same goes for %u and friends.

…signed long on '%d' and '%u' format specifiers.
@bakpakin bakpakin merged commit dbb2187 into janet-lang:master May 29, 2023
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