1
0
Fork 0
mirror of https://github.com/tobast/libunwind-eh_elf.git synced 2024-11-25 16:47:38 +01:00

Call snprintf() from signal handler only if required in test-async-sig

snprintf() is not guaranteed to be safely callable from a signal
handler, so avoid calling it in the default non-verbose case.
This commit is contained in:
Tommi Rantala 2012-08-16 10:25:56 +03:00
parent 7263a97ced
commit 848ad53a47

View file

@ -89,7 +89,8 @@ do_backtrace (int may_print, int get_proc_name)
buf[0] = '\0'; buf[0] = '\0';
if (get_proc_name || (may_print && verbose)) if (get_proc_name || (may_print && verbose))
{ {
if (unw_get_proc_name (&cursor, name, sizeof (name), &off) == 0) ret = unw_get_proc_name (&cursor, name, sizeof (name), &off);
if (ret == 0 && (may_print && verbose))
{ {
if (off) if (off)
snprintf (buf, sizeof (buf), "<%s+0x%lx>", name, (long) off); snprintf (buf, sizeof (buf), "<%s+0x%lx>", name, (long) off);