Skip to content

Commit

Permalink
8289049: x86_32 build fails with GCC 11 due to newString646_US warning
Browse files Browse the repository at this point in the history
Reviewed-by: alanb, stuefe
  • Loading branch information
shipilev committed Aug 17, 2022
1 parent bf7d6d3 commit 0c67fba
Showing 1 changed file with 6 additions and 2 deletions.
8 changes: 6 additions & 2 deletions src/java.base/share/native/libjava/jni_util.c
Original file line number Diff line number Diff line change
Expand Up @@ -393,7 +393,7 @@ JNU_NewObjectByName(JNIEnv *env, const char *class_name,
static jstring
newSizedString8859_1(JNIEnv *env, const char *str, const int len)
{
jchar buf[512];
jchar buf[512] = {0};
jchar *str1;
jstring result;
int i;
Expand All @@ -412,6 +412,7 @@ newSizedString8859_1(JNIEnv *env, const char *str, const int len)

for (i=0;i<len;i++)
str1[i] = (unsigned char)str[i];

result = (*env)->NewString(env, str1, len);
if (str1 != buf)
free(str1);
Expand Down Expand Up @@ -467,6 +468,9 @@ newString646_US(JNIEnv *env, const char *str)
jstring result;
int i;

if ((*env)->EnsureLocalCapacity(env, 1) < 0)
return NULL;

if (len > 512) {
str1 = (jchar *)malloc(len * sizeof(jchar));
if (str1 == 0) {
Expand Down Expand Up @@ -534,7 +538,7 @@ static jstring
newStringCp1252(JNIEnv *env, const char *str)
{
int len = (int) strlen(str);
jchar buf[512];
jchar buf[512] = {0};
jchar *str1;
jstring result;
int i;
Expand Down

1 comment on commit 0c67fba

@openjdk-notifier
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Please sign in to comment.