8286070: Improve UTF8 representation

Reviewed-by: bae
Backport-of: 3c40771d02b34027b53c8f3097e124ac9eddd030
This commit is contained in:
Yuri Nesterenko 2022-11-23 10:54:08 +03:00
parent 5a0cbd1d89
commit 9329d8e5b9

View File

@ -1,5 +1,5 @@
/*
* Copyright (c) 1997, 2019, Oracle and/or its affiliates. All rights reserved.
* Copyright (c) 1997, 2022, Oracle and/or its affiliates. All rights reserved.
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
*
* This code is free software; you can redistribute it and/or modify it
@ -885,6 +885,13 @@ getStringUTF8(JNIEnv *env, jstring jstr)
}
}
// Check `jint` overflow
if (rlen < 0) {
(*env)->ReleasePrimitiveArrayCritical(env, value, str, 0);
JNU_ThrowOutOfMemoryError(env, "requested array size exceeds VM limit");
return NULL;
}
result = MALLOC_MIN4(rlen);
if (result == NULL) {
(*env)->ReleasePrimitiveArrayCritical(env, value, str, 0);