From 8bcd871811ccea8b704264ce273843e7b1c508d1 Mon Sep 17 00:00:00 2001 From: Panu Matilainen Date: Thu, 18 Oct 2007 09:34:54 +0300 Subject: [PATCH] debugedit mishandles empty DW_AT_comp_dir (Roland McGrath) - fpc seems to produce DW_AT_comp_dir with value "" (empty string). This is dubious, but debugedit makes it even worse by getting confused by it. --- tools/debugedit.c | 15 ++++++++++----- 1 file changed, 10 insertions(+), 5 deletions(-) diff --git a/tools/debugedit.c b/tools/debugedit.c index 9206241..13ed1e1 100644 --- a/tools/debugedit.c +++ b/tools/debugedit.c @@ -560,11 +560,16 @@ edit_dwarf2_line (DSO *dso, uint_32 off, char *comp_dir, int phase) } else { - memcpy (s, comp_dir, comp_dir_len); - s[comp_dir_len] = '/'; - memcpy (s + comp_dir_len + 1, dirt[value], dir_len); - s[comp_dir_len + 1 + dir_len] = '/'; - memcpy (s + comp_dir_len + 1 + dir_len + 1, file, file_len + 1); + char *p = s; + if (comp_dir_len != 0) + { + memcpy (s, comp_dir, comp_dir_len); + s[comp_dir_len] = '/'; + p += comp_dir_len + 1; + } + memcpy (p, dirt[value], dir_len); + p[dir_len] = '/'; + memcpy (p + dir_len + 1, file, file_len + 1); } canonicalize_path (s, s); if (list_file_fd != -1) -- 2.7.4