Skip to content

Commit 0c67fba

Browse files
committed
8289049: x86_32 build fails with GCC 11 due to newString646_US warning
Reviewed-by: alanb, stuefe
1 parent bf7d6d3 commit 0c67fba

File tree

1 file changed

+6
-2
lines changed

1 file changed

+6
-2
lines changed

src/java.base/share/native/libjava/jni_util.c

+6-2
Original file line numberDiff line numberDiff line change
@@ -393,7 +393,7 @@ JNU_NewObjectByName(JNIEnv *env, const char *class_name,
393393
static jstring
394394
newSizedString8859_1(JNIEnv *env, const char *str, const int len)
395395
{
396-
jchar buf[512];
396+
jchar buf[512] = {0};
397397
jchar *str1;
398398
jstring result;
399399
int i;
@@ -412,6 +412,7 @@ newSizedString8859_1(JNIEnv *env, const char *str, const int len)
412412

413413
for (i=0;i<len;i++)
414414
str1[i] = (unsigned char)str[i];
415+
415416
result = (*env)->NewString(env, str1, len);
416417
if (str1 != buf)
417418
free(str1);
@@ -467,6 +468,9 @@ newString646_US(JNIEnv *env, const char *str)
467468
jstring result;
468469
int i;
469470

471+
if ((*env)->EnsureLocalCapacity(env, 1) < 0)
472+
return NULL;
473+
470474
if (len > 512) {
471475
str1 = (jchar *)malloc(len * sizeof(jchar));
472476
if (str1 == 0) {
@@ -534,7 +538,7 @@ static jstring
534538
newStringCp1252(JNIEnv *env, const char *str)
535539
{
536540
int len = (int) strlen(str);
537-
jchar buf[512];
541+
jchar buf[512] = {0};
538542
jchar *str1;
539543
jstring result;
540544
int i;

0 commit comments

Comments
 (0)