Content-Length: 200520 | pFad | http://github.com/xerial/snappy-java/issues/629

35 Bad use of OutOfMemoryError to validate buffer size · Issue #629 · xerial/snappy-java · GitHub
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

Bad use of OutOfMemoryError to validate buffer size #629

Open
duongkame opened this issue Jan 8, 2025 · 0 comments
Open

Bad use of OutOfMemoryError to validate buffer size #629

duongkame opened this issue Jan 8, 2025 · 0 comments

Comments

@duongkame
Copy link

In SnappyInputStream, OutOfMemoryError is used to validate the buffer size to allocated.

try {
compressed = new byte[chunkSize];
}
catch (java.lang.OutOfMemoryError e) {
throw new SnappyError(SnappyErrorCode.INVALID_CHUNK_SIZE, e.getMessage());
}

This's a bad way to validate buffer size as explain here.
And another serious consequence, catching OutOfMemoryError in Java code requires the applications not to use JVM options like CrashOnOutOfMemoryError or ExitOnOutOfMemoryError to automatically restart the JVM when it runs out of memory.

I'm wondering if there is a specific reason why that could not be a simple conditional validation?

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








ApplySandwichStrip

pFad - (p)hone/(F)rame/(a)nonymizer/(d)eclutterfier!      Saves Data!


--- a PPN by Garber Painting Akron. With Image Size Reduction included!

Fetched URL: http://github.com/xerial/snappy-java/issues/629

Alternative Proxies:

Alternative Proxy

pFad Proxy

pFad v3 Proxy

pFad v4 Proxy