]> git.ipfire.org Git - thirdparty/dovecot/core.git/commitdiff
lib: backtrace_append() - If libunwind fails to get any symbols, return error
authorTimo Sirainen <timo.sirainen@open-xchange.com>
Thu, 13 Jun 2019 13:37:34 +0000 (16:37 +0300)
committerAki Tuomi <aki.tuomi@open-xchange.com>
Wed, 9 Oct 2019 07:58:25 +0000 (07:58 +0000)
src/lib/backtrace-string.c

index 7885116753e9f31c03c866f9a9b89305dff98a8a..d9845e7a17493a5d043af9e839e74f15332a43c6 100644 (file)
@@ -19,6 +19,7 @@ int backtrace_append(string_t *str)
        unw_cursor_t c;
        unw_context_t ctx;
        unw_proc_info_t pip;
+       bool success = FALSE;
 
        if ((ret = unw_getcontext(&ctx)) != 0) {
                str_printfa(str, "unw_getcontext() failed: %d", ret);
@@ -45,6 +46,7 @@ int backtrace_append(string_t *str)
                } else {
                        str_append_max(str, proc_name, sizeof(proc_name));
                        str_printfa(str, "[0x%08lx]", pip.start_ip);
+                       success = TRUE;
                }
                str_append(str, " -> ");
                fp++;
@@ -53,7 +55,7 @@ int backtrace_append(string_t *str)
        /* remove ' -> ' */
        if (str->used > 4)
                str_truncate(str, str->used - 4);
-       return ret == 0 ? 0 : -1;
+       return ret == 0 && success ? 0 : -1;
 }
 
 #elif defined(HAVE_BACKTRACE_SYMBOLS) && defined(HAVE_EXECINFO_H)