In the ngspice shared library the fcn ivers is called

with a NULL argument. The fix safeguards against argv0
being NULL.
In this case Spice_Exec_Path is set to NULL, it is
safeguarded against NULL when being used.
This commit is contained in:
Holger Vogt 2023-01-30 10:56:03 +01:00
parent dff212c630
commit 2d936f1e8f
1 changed files with 14 additions and 10 deletions

View File

@ -105,19 +105,23 @@ ivars(char *argv0)
AsciiRawFile = atoi(temp); AsciiRawFile = atoi(temp);
/* path of the ngspice executable */ /* path of the ngspice executable */
Spice_Exec_Path = copy(argv0); if (argv0) {
/* find the last occurence of "ngspice" in Spice_Exec_Path */ Spice_Exec_Path = copy(argv0);
char* path_end = strstr(Spice_Exec_Path, "ngspice"); /* find the last occurence of "ngspice" in Spice_Exec_Path */
if (path_end) { char* path_end = strstr(Spice_Exec_Path, "ngspice");
char* exec_only = strstr(path_end + 7, "ngspice"); if (path_end) {
while (exec_only) { char* exec_only = strstr(path_end + 7, "ngspice");
path_end = strstr(exec_only, "ngspice"); while (exec_only) {
path_end = strstr(exec_only, "ngspice");
if (path_end)
exec_only = strstr(path_end + 7, "ngspice");
}
if (path_end) if (path_end)
exec_only = strstr(path_end + 7, "ngspice"); *path_end = '\0';
} }
if (path_end)
*path_end = '\0';
} }
else
Spice_Exec_Path = NULL;
} }
void void