Set_program_directory(): check return value of readlink()

This commit is contained in:
Thomas Bernard 2018-03-20 12:09:13 +01:00
parent c55c41fe83
commit 91e6796b92

View File

@ -106,9 +106,11 @@ void Set_program_directory(const char * argv0, char * program_dir)
if (argv0[0]!='/') if (argv0[0]!='/')
{ {
char path[PATH_MAX]; char path[PATH_MAX];
readlink("/proc/self/exe", path, sizeof(path)); if (readlink("/proc/self/exe", path, sizeof(path)) >= 0)
Extract_path(program_dir, path); {
return; Extract_path(program_dir, path);
return;
}
} }
Extract_path(program_dir, argv0); Extract_path(program_dir, argv0);