diff --git a/src/java.base/share/native/libjava/jni_util.c b/src/java.base/share/native/libjava/jni_util.c index 43a2ac5440a..1090170dff3 100644 --- a/src/java.base/share/native/libjava/jni_util.c +++ b/src/java.base/share/native/libjava/jni_util.c @@ -39,7 +39,7 @@ * negative, or the size is INT_MAX as the macro adds 1 * that overflows into negative value. */ -#define MALLOC_MIN4(len) ((unsigned)(len) >= INT_MAX ? \ +#define MALLOC_MIN4(len) ((len) >= INT_MAX || (len) < 0 ? \ NULL : \ ((char *)malloc((len) + 1 < 4 ? 4 : (len) + 1)))