You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@subversion.apache.org by br...@apache.org on 2013/11/10 16:24:46 UTC
svn commit: r1540483 -
/subversion/trunk/subversion/bindings/javahl/native/jniwrapper/jni_array.hpp
Author: brane
Date: Sun Nov 10 15:24:46 2013
New Revision: 1540483
URL: http://svn.apache.org/r1540483
Log:
Make the JavaHL ByteArray wrapper more consistent with the String wrapper.
* subversion/bindings/javahl/native/jniwrapper/jni_array.hpp:
(ByteArray::ByteArray): Initialize the length of a null array to 0.
(ByteArray::Contents::Contents): Do not get the elements of a null array.
(ByteArray::Contents::get_string): Protect against null contents.
Modified:
subversion/trunk/subversion/bindings/javahl/native/jniwrapper/jni_array.hpp
Modified: subversion/trunk/subversion/bindings/javahl/native/jniwrapper/jni_array.hpp
URL: http://svn.apache.org/viewvc/subversion/trunk/subversion/bindings/javahl/native/jniwrapper/jni_array.hpp?rev=1540483&r1=1540482&r2=1540483&view=diff
==============================================================================
--- subversion/trunk/subversion/bindings/javahl/native/jniwrapper/jni_array.hpp (original)
+++ subversion/trunk/subversion/bindings/javahl/native/jniwrapper/jni_array.hpp Sun Nov 10 15:24:46 2013
@@ -47,7 +47,7 @@ public:
*/
explicit ByteArray(Env env, jbyteArray array)
: m_env(env),
- m_length(array ? m_env.GetArrayLength(array) : -1),
+ m_length(array ? m_env.GetArrayLength(array) : 0),
m_array(array)
{}
@@ -122,7 +122,8 @@ public:
*/
explicit Contents(const ByteArray& array)
: m_array(array),
- m_data(array.m_env.GetByteArrayElements(array.m_array, NULL))
+ m_data(!array.m_array ? NULL
+ : array.m_env.GetByteArrayElements(array.m_array, NULL))
{}
/**
@@ -160,8 +161,10 @@ public:
*/
svn_string_t* get_string(const ::SVN::Pool& result_pool) const
{
- return svn_string_ncreate(data(), m_array.m_length,
- result_pool.getPool());
+ if (m_data)
+ return svn_string_ncreate(data(), m_array.m_length,
+ result_pool.getPool());
+ return NULL;
}
protected: