diff --git a/src/main/cpp/ShortArray.cpp b/src/main/cpp/ShortArray.cpp index bae5531..8e8adb9 100644 --- a/src/main/cpp/ShortArray.cpp +++ b/src/main/cpp/ShortArray.cpp @@ -101,7 +101,7 @@ void ShortArray::set(JNIEnv *env, jshortArray data) { if (_num_elements == 0) { _data = NULL; } else { - _data = (short *)malloc(_num_elements); + _data = (short *)malloc(_num_elements * sizeof(jshort)); env->GetShortArrayRegion(data, 0, (jsize)_num_elements, (jshort *)_data); } } diff --git a/src/main/cpp/ShortArray.h b/src/main/cpp/ShortArray.h index 6c6ef5c..a15a6fc 100644 --- a/src/main/cpp/ShortArray.h +++ b/src/main/cpp/ShortArray.h @@ -64,7 +64,7 @@ class EXPORT ShortArray { /** * @brief Get a pointer to the natively stored data */ - const void* get() const { return _data; } + short* get() const { return _data; } /** * @brief Convert data to a Java byte[] array