libunwind-devel
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[Libunwind-devel] [PATCH 30/57] Call snprintf() from signal handler only


From: Tommi Rantala
Subject: [Libunwind-devel] [PATCH 30/57] Call snprintf() from signal handler only if required in test-async-sig
Date: Fri, 21 Sep 2012 14:11:31 +0300

snprintf() is not guaranteed to be safely callable from a signal
handler, so avoid calling it in the default non-verbose case.
---
 tests/test-async-sig.c |    3 ++-
 1 file changed, 2 insertions(+), 1 deletion(-)

diff --git a/tests/test-async-sig.c b/tests/test-async-sig.c
index ba37c90..9a0d39e 100644
--- a/tests/test-async-sig.c
+++ b/tests/test-async-sig.c
@@ -89,7 +89,8 @@ do_backtrace (int may_print, int get_proc_name)
       buf[0] = '\0';
       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)
                snprintf (buf, sizeof (buf), "<%s+0x%lx>", name, (long) off);
-- 
1.7.9.5




reply via email to

[Prev in Thread] Current Thread [Next in Thread]