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); } }