Skip `NULL` values from `dladdr(3)`

Fixes [Bug #17810]
This commit is contained in:
xtkoba 2021-04-30 23:03:02 +09:00 коммит произвёл Yusuke Endoh
Родитель 4e21b19a61
Коммит 940c8b093d
1 изменённых файлов: 7 добавлений и 5 удалений

Просмотреть файл

@ -2329,8 +2329,8 @@ rb_dump_backtrace_with_lines(int num_traces, void **traces)
/* if the binary is strip-ed, this may effect */
for (p=dladdr_fbases; *p; p++) {
if (*p == info.dli_fbase) {
lines[i].path = info.dli_fname;
lines[i].sname = info.dli_sname;
if (info.dli_fname) lines[i].path = info.dli_fname;
if (info.dli_sname) lines[i].sname = info.dli_sname;
goto next_line;
}
}
@ -2340,9 +2340,11 @@ rb_dump_backtrace_with_lines(int num_traces, void **traces)
obj->base_addr = (uintptr_t)info.dli_fbase;
path = info.dli_fname;
obj->path = path;
lines[i].path = path;
lines[i].sname = info.dli_sname;
lines[i].saddr = (uintptr_t)info.dli_saddr;
if (path) lines[i].path = path;
if (info.dli_sname) {
lines[i].sname = info.dli_sname;
lines[i].saddr = (uintptr_t)info.dli_saddr;
}
strlcpy(binary_filename, path, PATH_MAX);
if (fill_lines(num_traces, traces, 1, &obj, lines, i) == (uintptr_t)-1)
break;