Skip to content

Commit

Permalink
n64sym: fix the previous fix for \r
Browse files Browse the repository at this point in the history
  • Loading branch information
rasky committed Aug 29, 2023
1 parent 77a182b commit f28708c
Showing 1 changed file with 3 additions and 2 deletions.
5 changes: 3 additions & 2 deletions tools/n64sym.c
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Expand Down

0 comments on commit f28708c

Please sign in to comment.