From 6bf097c0f24e1b6b222f4b94d05906ee7201f6cf Mon Sep 17 00:00:00 2001 From: Zdenek Zambersky Date: Wed, 10 Sep 2025 18:40:40 +0200 Subject: [PATCH] Backport 651ba865c1afe2b29adc5b0ca428117200313912 --- src/java.base/share/native/libjli/java.c | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/src/java.base/share/native/libjli/java.c b/src/java.base/share/native/libjli/java.c index a38ddae63d1..34760f3ea6c 100644 --- a/src/java.base/share/native/libjli/java.c +++ b/src/java.base/share/native/libjli/java.c @@ -1,5 +1,5 @@ /* - * Copyright (c) 1995, 2020, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 1995, 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 @@ -51,6 +51,8 @@ */ +#include + #include "java.h" #include "jni.h" @@ -1695,7 +1697,8 @@ TranslateApplicationArgs(int jargc, const char **jargv, int *pargc, char ***parg for (i = 0; i < jargc; i++) { const char *arg = jargv[i]; if (arg[0] == '-' && arg[1] == 'J') { - *nargv++ = ((arg + 2) == NULL) ? NULL : JLI_StringDup(arg + 2); + assert(arg[2] != '\0' && "Invalid JAVA_ARGS or EXTRA_JAVA_ARGS defined by build"); + *nargv++ = JLI_StringDup(arg + 2); } }