Skip to content

Commit

Permalink
Fixes another address that can't be NULL
Browse files Browse the repository at this point in the history
The variable 'ProcessName' is an array of 'char', it can't be NULL, so
don't check for it.

Make sure that the variable 'proc_name' is initialized to NULL. Change
how we copy the string from malloc() and strcpy() to strndup(). As with
malloc() we don't check the result, this is done before usage.
  • Loading branch information
havardAasen committed Dec 27, 2023
1 parent 8d9c5aa commit c715355
Showing 1 changed file with 2 additions and 6 deletions.
8 changes: 2 additions & 6 deletions src/libnml/nml/nml_mod.cc
Original file line number Diff line number Diff line change
Expand Up @@ -163,6 +163,7 @@ NML_MODULE::zero_common_vars ()
min_run_time = 1e6;
max_run_time = 0;
start_cycle_time = 0;
proc_name = 0;
temp_file = 0;
temp_line = 0;
Dclock_expiration = 0;
Expand Down Expand Up @@ -271,12 +272,7 @@ NML_MODULE::setCmdChannel (RCS_CMD_CHANNEL * cmd_channel)
}
if (NULL != commandIn->cms)
{
if (NULL != commandIn->cms->ProcessName)
{
proc_name =
(char *) malloc (strlen (commandIn->cms->ProcessName) + 1);
strcpy (proc_name, commandIn->cms->ProcessName);
}
proc_name = strndup(commandIn->cms->ProcessName, LINELEN);
}
}

Expand Down

0 comments on commit c715355

Please sign in to comment.