From f28708cec0bee3ed98cdcf660246846cd9a26c13 Mon Sep 17 00:00:00 2001 From: Giovanni Bajo Date: Tue, 29 Aug 2023 15:43:25 +0200 Subject: [PATCH] n64sym: fix the previous fix for \r --- tools/n64sym.c | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/tools/n64sym.c b/tools/n64sym.c index b947e94316..3dfbc55834 100644 --- a/tools/n64sym.c +++ b/tools/n64sym.c @@ -150,13 +150,14 @@ void symbol_add(const char *elf, uint32_t addr, bool is_func) // it means that we're done. int n = getline(&line_buf, &line_buf_size, addr2line_r); if (strncmp(line_buf, "0xffffffff", 10) == 0) break; + n--; if (line_buf[n-1] == '\r') n--; // Remove trailing \r (Windows) // If the function of name is longer than 64 bytes, truncate it. This also // avoid paradoxically long function names like in C++ that can even be // several thousands of characters long. - char *func = strndup(line_buf, MIN(n-1, flag_max_sym_len)); - if (n-1 > flag_max_sym_len) strcpy(&func[flag_max_sym_len-3], "..."); + char *func = strndup(line_buf, MIN(n, flag_max_sym_len)); + if (n > flag_max_sym_len) strcpy(&func[flag_max_sym_len-3], "..."); // Second line is the file name and line number getline(&line_buf, &line_buf_size, addr2line_r);