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

jni: fix support for non-direct byte buffers #1950

Merged
merged 2 commits into from
Nov 30, 2021
Merged

jni: fix support for non-direct byte buffers #1950

merged 2 commits into from
Nov 30, 2021

Conversation

goaway
Copy link
Contributor

@goaway goaway commented Nov 29, 2021

Description: #1906 introduced path whereby the check for whether a buffer is direct was skipped, then treated the -1 value returned by the capacity check as an unsigned size for allocation. This fix ensures the check always happens.
Risk Level: Low
Testing: Kotlin integration tests need to be re-enabled.

Signed-off-by: Mike Schore mike.schore@gmail.com

Signed-off-by: Mike Schore <mike.schore@gmail.com>
// Returns -1 if the buffer is not a direct buffer.
jlong data_length = env->GetDirectBufferCapacity(j_data);

if (data_length < 0) {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I really missed a step with my "ultra safe refactoring"...

Thanks!

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

No worries - I actually think our integration tests would have caught it; they're just unfortunately turned off at the moment. I intend to fix them up and re-enable them in the near future. :)

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Signed-off-by: Mike Schore <mike.schore@gmail.com>
Copy link
Member

@junr03 junr03 left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I have not had the chance to test on the Lyft apps (where I originally encountered the problem). But given @carloseltuerto approval I feel comfortable approving.

@goaway goaway merged commit 566a184 into main Nov 30, 2021
@goaway goaway deleted the ms/jni-fix branch November 30, 2021 17:42
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.

3 participants