Skip to content

Commit

Permalink
Merge pull request #16842 from tajila/criu_3
Browse files Browse the repository at this point in the history
Add NULL check for VM args array
  • Loading branch information
gacholio authored Mar 8, 2023
2 parents 2bcb989 + 1f6558f commit ec80c9b
Showing 1 changed file with 10 additions and 10 deletions.
20 changes: 10 additions & 10 deletions runtime/util/vmargs.c
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/*******************************************************************************
* Copyright (c) 1991, 2021 IBM Corp. and others
* Copyright (c) 1991, 2023 IBM Corp. and others
*
* This program and the accompanying materials are made available under
* the terms of the Eclipse Public License 2.0 which accompanies this
Expand Down Expand Up @@ -95,7 +95,7 @@ findArgInVMArgs(J9PortLibrary *portLibrary, J9VMInitArgs* j9vm_args, UDATA match

PORT_ACCESS_FROM_PORT(portLibrary);

if (optionName==NULL || 0==j9vm_args->nOptions) {
if ((NULL == optionName) || (NULL == j9vm_args) || (0 == j9vm_args->nOptions)) {
return returnVal;
}

Expand Down Expand Up @@ -648,7 +648,7 @@ optionValueOperations(J9PortLibrary *portLibrary, J9VMInitArgs* j9vm_args, IDATA
return OPTION_OK;
}

static char *
static char *
getStartOfOptionValue(J9VMInitArgs* j9vm_args, IDATA element, const char *optionName)
{
const char *option = optionName;
Expand All @@ -659,7 +659,7 @@ getStartOfOptionValue(J9VMInitArgs* j9vm_args, IDATA element, const char *option
}

Assert_Util_true(NULL != option);

value = j9vm_args->actualVMArgs->options[element].optionString + strlen(option);

return value;
Expand Down Expand Up @@ -690,7 +690,7 @@ addXjcl(J9PortLibrary * portLib, J9JavaVMArgInfoList *vmArgumentsList, UDATA j2s
char *argString = NULL;
UDATA j2seReleaseValue = j2seVersion & J2SE_RELEASE_MASK;
J9JavaVMArgInfo *optArg = NULL;

PORT_ACCESS_FROM_PORT(portLib);
#ifdef J9VM_IVE_RAW_BUILD /* J9VM_IVE_RAW_BUILD is not enabled by default */
Assert_Util_unreachable();
Expand Down Expand Up @@ -1058,7 +1058,7 @@ addExtDir(J9PortLibrary *portLib, J9JavaVMArgInfoList *vmArgumentsList, char *jr
}

IDATA
addUserDir(J9PortLibrary * portLib, J9JavaVMArgInfoList *vmArgumentsList, char *cwd)
addUserDir(J9PortLibrary * portLib, J9JavaVMArgInfoList *vmArgumentsList, char *cwd)
{
size_t argumentLength = 1; /* space for the \0 */
char *optionsArgumentBuffer = NULL;
Expand Down Expand Up @@ -1302,7 +1302,7 @@ addJarArguments(J9PortLibrary * portLib, J9JavaVMArgInfoList *vmArgumentsList, c
* @return 0 on success, negative on failure
*/
static IDATA
mapEnvVarToArgument(J9PortLibrary* portLibrary, const char* envVar, const char* j9opt, J9JavaVMArgInfoList *vmArgumentsList, UDATA mapType, UDATA verboseFlags)
mapEnvVarToArgument(J9PortLibrary* portLibrary, const char* envVar, const char* j9opt, J9JavaVMArgInfoList *vmArgumentsList, UDATA mapType, UDATA verboseFlags)
{
J9JavaVMArgInfo *optArg = NULL;
IDATA valueSize = 0;
Expand Down Expand Up @@ -1363,7 +1363,7 @@ mapEnvVarToArgument(J9PortLibrary* portLibrary, const char* envVar, const char*


IDATA
addEnvironmentVariableArguments(J9PortLibrary *portLib, const char *envVarName, J9JavaVMArgInfoList *vmArgumentsList, UDATA verboseFlags)
addEnvironmentVariableArguments(J9PortLibrary *portLib, const char *envVarName, J9JavaVMArgInfoList *vmArgumentsList, UDATA verboseFlags)
{
PORT_ACCESS_FROM_PORT(portLib);
IDATA envVarSize = j9sysinfo_get_env(envVarName, NULL, 0);
Expand All @@ -1383,7 +1383,7 @@ addEnvironmentVariableArguments(J9PortLibrary *portLib, const char *envVarName,
}

IDATA
addEnvironmentVariables(J9PortLibrary *portLib, JavaVMInitArgs *launcherArgs, J9JavaVMArgInfoList *vmArgumentsList, UDATA verboseFlags)
addEnvironmentVariables(J9PortLibrary *portLib, JavaVMInitArgs *launcherArgs, J9JavaVMArgInfoList *vmArgumentsList, UDATA verboseFlags)
{
IDATA status = 0;
if (
Expand Down Expand Up @@ -1536,7 +1536,7 @@ addLauncherArgs(J9PortLibrary * portLib, JavaVMInitArgs *launcherArgs, UDATA lau
}

IDATA
addXserviceArgs(J9PortLibrary * portLib, J9JavaVMArgInfoList *vmArgumentsList, char *xServiceBuffer, UDATA verboseFlags)
addXserviceArgs(J9PortLibrary * portLib, J9JavaVMArgInfoList *vmArgumentsList, char *xServiceBuffer, UDATA verboseFlags)
{

PORT_ACCESS_FROM_PORT(portLib);
Expand Down

0 comments on commit ec80c9b

Please sign in to comment.