This is an automated email from the ASF dual-hosted git repository.
schultz pushed a commit to branch 1.3.x
in repository https://gitbox.apache.org/repos/asf/tomcat-native.git
The following commit(s) were added to refs/heads/1.3.x by this push:
new b75a3f198 Ensure local reference capacity is available for array
allocations.
b75a3f198 is described below
commit b75a3f1985c6b642556179d01fb1e298d41146fd
Author: Christopher Schultz <[email protected]>
AuthorDate: Thu May 16 09:51:45 2024 -0400
Ensure local reference capacity is available for array allocations.
---
native/src/jnilib.c | 14 ++++++++++++--
1 file changed, 12 insertions(+), 2 deletions(-)
diff --git a/native/src/jnilib.c b/native/src/jnilib.c
index f46774ac2..65f889eca 100644
--- a/native/src/jnilib.c
+++ b/native/src/jnilib.c
@@ -156,6 +156,9 @@ jstring tcn_new_stringn(JNIEnv *env, const char *str,
size_t l)
jbyteArray tcn_new_arrayb(JNIEnv *env, const unsigned char *data, size_t len)
{
+ if ((*env)->EnsureLocalCapacity(env, 1) < 0) {
+ return NULL; /* out of memory error */
+ }
jbyteArray bytes = (*env)->NewByteArray(env, (jsize)len);
if (bytes != NULL) {
(*env)->SetByteArrayRegion(env, bytes, 0, (jint)len, (jbyte *)data);
@@ -165,15 +168,22 @@ jbyteArray tcn_new_arrayb(JNIEnv *env, const unsigned
char *data, size_t len)
jobjectArray tcn_new_arrays(JNIEnv *env, size_t len)
{
+ if ((*env)->EnsureLocalCapacity(env, 1) < 0) {
+ return NULL; /* out of memory error */
+ }
return (*env)->NewObjectArray(env, (jsize)len, jString_class, NULL);
}
jstring tcn_new_string(JNIEnv *env, const char *str)
{
- if (!str)
+ if (!str) {
return NULL;
- else
+ } else {
+ if ((*env)->EnsureLocalCapacity(env, 1) < 0) {
+ return NULL; /* out of memory error */
+ }
return (*env)->NewStringUTF(env, str);
+ }
}
char *tcn_get_string(JNIEnv *env, jstring jstr)
---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]