You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
XXHashJNI uses a stale local class reference for OutOfMemoryError and does not check createState results #100
init stores the result of FindClass(env, "java/lang/OutOfMemoryError") in the static OutOfMemoryError field. That is a local reference, and it is freed once init returns. throw_OOM (line 34) then calls ThrowNew with the dangling reference.
You can reach this from the public API without memory pressure. A zero-length FileChannel.map(mode, 0, 0) buffer reports isDirect() == true but has a NULL native address, so GetDirectBufferAddress returns NULL and throw_OOM runs:
Optionally, XXH32BB/XXH64BB could return the hash of the empty input when the address is NULL and len == 0, instead of throwing.
2. Missing NULL checks on XXH*_createState (lines 92, 202)
The result of XXH32_createState() / XXH64_createState() is passed straight to XXH*_reset. If malloc fails, that dereferences NULL and crashes the JVM. Fix: if (state == NULL) { throw_OOM(env); return 0; }. This depends on fix 1.
Activity
Fix stale OutOfMemoryError reference in XXHashJNI (#127)