Skip to content
This repository has been archived by the owner on Sep 21, 2020. It is now read-only.

Commit

Permalink
Fix JArrayRef DirectBuffer destructor.
Browse files Browse the repository at this point in the history
Previously it would try to release array elements even if the DirectBuffer
constructor was used.
  • Loading branch information
PeterJohnson committed Dec 15, 2016
1 parent ce76115 commit 9939527
Showing 1 changed file with 2 additions and 2 deletions.
4 changes: 2 additions & 2 deletions wpiutil/include/support/jni_util.h
Original file line number Diff line number Diff line change
Expand Up @@ -167,7 +167,7 @@ class JArrayRefBase : public JArrayRefInner<JArrayRefBase<T>, T> {
m_elements = env->Get##F##ArrayElements(jarr, nullptr); \
} \
~J##F##ArrayRef() { \
if (m_elements) \
if (m_jarr && m_elements) \
m_env->Release##F##ArrayElements(static_cast<T##Array>(m_jarr), \
m_elements, JNI_ABORT); \
} \
Expand All @@ -181,7 +181,7 @@ class JArrayRefBase : public JArrayRefInner<JArrayRefBase<T>, T> {
static_cast<T *>(env->GetPrimitiveArrayCritical(jarr, nullptr)); \
} \
~CriticalJ##F##ArrayRef() { \
if (m_elements) \
if (m_jarr && m_elements) \
m_env->ReleasePrimitiveArrayCritical(m_jarr, m_elements, JNI_ABORT); \
} \
};
Expand Down

0 comments on commit 9939527

Please sign in to comment.