Skip to content

Delete local references to Java-returned result arrays in JNI callbacks - #1016

Merged
normanmaurer merged 1 commit into
mainfrom
local_refs
Sep 21, 2026
Merged

normanmaurer merged 1 commit into
mainfrom
local_refs

Conversation

@normanmaurer

Copy link
Copy Markdown
Member

Motivation:

resultArray in cert_compress.c compress()/decompress() and resultBytes
in the SSL_PRIVATE_KEY_METHOD callbacks in sslcontext.c are obtained
from CallObjectMethod/GetObjectField but were never deleted on any
exit path. These are invoked repeatedly as native callbacks from
OpenSSL/BoringSSL (once per certificate needing (de)compression, or
per sign/decrypt/complete call), so the leaked local references
accumulate and can exhaust the JNI local reference table.

Modifications:

  • cert_compress.c: delete resultArray before every return in compress()
    and decompress() once it has been obtained.
  • sslcontext.c: delete resultBytes at the complete: label in
    tcn_private_key_sign_java and tcn_private_key_decrypt_java, and
    before every return in tcn_private_key_complete_java.

Result:

No longer leak local references to compression/private-key callback
result arrays.

Motivation:

resultArray in cert_compress.c compress()/decompress() and resultBytes
in the SSL_PRIVATE_KEY_METHOD callbacks in sslcontext.c are obtained
from CallObjectMethod/GetObjectField but were never deleted on any
exit path. These are invoked repeatedly as native callbacks from
OpenSSL/BoringSSL (once per certificate needing (de)compression, or
per sign/decrypt/complete call), so the leaked local references
accumulate and can exhaust the JNI local reference table.

Modifications:

- cert_compress.c: delete resultArray before every return in compress()
  and decompress() once it has been obtained.
- sslcontext.c: delete resultBytes at the complete: label in
  tcn_private_key_sign_java and tcn_private_key_decrypt_java, and
  before every return in tcn_private_key_complete_java.

Result:

No longer leak local references to compression/private-key callback
result arrays.
@normanmaurer normanmaurer added this to the 2.0.85.Final milestone Sep 20, 2026
@normanmaurer
normanmaurer merged commit 64edccd into main Sep 21, 2026
10 of 11 checks passed
@normanmaurer
normanmaurer deleted the local_refs branch September 21, 2026 07:26
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