addr2line.c (main_exe_path): avoid SEGV when /proc is not available

readlink would return -1 if /proc is not mounted.
Coverity Scan found this issue.
This commit is contained in:
Yusuke Endoh 2019-07-14 17:53:45 +09:00
parent 47e571c951
commit db1c30b37f
1 changed files with 1 additions and 0 deletions

View File

@ -2050,6 +2050,7 @@ main_exe_path(void)
{
# define PROC_SELF_EXE "/proc/self/exe"
ssize_t len = readlink(PROC_SELF_EXE, binary_filename, PATH_MAX);
if (len < 0) return 0;
binary_filename[len] = 0;
return len;
}