Skip to content

Commit 940c8b0

Browse files
xtkobamame
authored andcommitted
Skip NULL values from dladdr(3)
Fixes [Bug #17810]
1 parent 4e21b19 commit 940c8b0

File tree

1 file changed

+7
-5
lines changed

1 file changed

+7
-5
lines changed

addr2line.c

Lines changed: 7 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -2329,8 +2329,8 @@ rb_dump_backtrace_with_lines(int num_traces, void **traces)
23292329
/* if the binary is strip-ed, this may effect */
23302330
for (p=dladdr_fbases; *p; p++) {
23312331
if (*p == info.dli_fbase) {
2332-
lines[i].path = info.dli_fname;
2333-
lines[i].sname = info.dli_sname;
2332+
if (info.dli_fname) lines[i].path = info.dli_fname;
2333+
if (info.dli_sname) lines[i].sname = info.dli_sname;
23342334
goto next_line;
23352335
}
23362336
}
@@ -2340,9 +2340,11 @@ rb_dump_backtrace_with_lines(int num_traces, void **traces)
23402340
obj->base_addr = (uintptr_t)info.dli_fbase;
23412341
path = info.dli_fname;
23422342
obj->path = path;
2343-
lines[i].path = path;
2344-
lines[i].sname = info.dli_sname;
2345-
lines[i].saddr = (uintptr_t)info.dli_saddr;
2343+
if (path) lines[i].path = path;
2344+
if (info.dli_sname) {
2345+
lines[i].sname = info.dli_sname;
2346+
lines[i].saddr = (uintptr_t)info.dli_saddr;
2347+
}
23462348
strlcpy(binary_filename, path, PATH_MAX);
23472349
if (fill_lines(num_traces, traces, 1, &obj, lines, i) == (uintptr_t)-1)
23482350
break;

0 commit comments

Comments
 (0)