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

Avoid asking for arrays that are too big. #141

Open
certainmagic opened this issue Dec 1, 2020 · 0 comments
Open

Avoid asking for arrays that are too big. #141

certainmagic opened this issue Dec 1, 2020 · 0 comments

Comments

@certainmagic
Copy link
Contributor

If someone tries to serialize a json structure that's too close to Integer.MAX_VALUE bytes, ByteArrayOutputStream will fail while trying to grow its array. The failure is particularly annoying because it's an OutOfMemoryError and it will kill the JVM. The exception's message is "Requested array size exceeds VM limit".

It'd be nice if we threw a B2JsonException instead of killing the JVM. ;)

I know this can happen during serialization. We should also look for other places we use a ByteArrayOutputStream and places we might allocate an array more directly.

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

No branches or pull requests

1 participant