diff options
author | Martin Liska <mliska@suse.cz> | 2019-01-24 09:27:39 +0100 |
---|---|---|
committer | Martin Liska <marxin@gcc.gnu.org> | 2019-01-24 08:27:39 +0000 |
commit | 12502bf2e905cba16edf28941a37e6de432ea108 (patch) | |
tree | 3bb6d2911140400e28773f6ab238f857c25988d5 /gcc | |
parent | 07fd2247eed45cd69c7b2294fe528c9bbe7a838e (diff) | |
download | gcc-12502bf2e905cba16edf28941a37e6de432ea108.zip gcc-12502bf2e905cba16edf28941a37e6de432ea108.tar.gz gcc-12502bf2e905cba16edf28941a37e6de432ea108.tar.bz2 |
Fix broken filename for .gcda files starting with '..' (PR gcov-profile/88994).
2019-01-24 Martin Liska <mliska@suse.cz>
PR gcov-profile/88994
* gcov-io.c (mangle_path): Do not allocate a bigger buffer,
result will be always smaller or equal to the original.
* gcov.c (mangle_name): Fix else branch where we should
also copy to PTR and shift the pointer.
From-SVN: r268233
Diffstat (limited to 'gcc')
-rw-r--r-- | gcc/ChangeLog | 8 | ||||
-rw-r--r-- | gcc/gcov-io.c | 2 | ||||
-rw-r--r-- | gcc/gcov.c | 16 |
3 files changed, 18 insertions, 8 deletions
diff --git a/gcc/ChangeLog b/gcc/ChangeLog index 56dbfa0..f7013b7 100644 --- a/gcc/ChangeLog +++ b/gcc/ChangeLog @@ -1,3 +1,11 @@ +2019-01-24 Martin Liska <mliska@suse.cz> + + PR gcov-profile/88994 + * gcov-io.c (mangle_path): Do not allocate a bigger buffer, + result will be always smaller or equal to the original. + * gcov.c (mangle_name): Fix else branch where we should + also copy to PTR and shift the pointer. + 2019-01-24 Xiong Hu Luo <luoxhu@linux.vnet.ibm.com> * tree-ssa-dom.c (test_for_singularity): fix a comment typo. diff --git a/gcc/gcov-io.c b/gcc/gcov-io.c index e3b1c5c..1f8ac37 100644 --- a/gcc/gcov-io.c +++ b/gcc/gcov-io.c @@ -547,7 +547,7 @@ mangle_path (char const *base) /* Convert '/' to '#', convert '..' to '^', convert ':' to '~' on DOS based file system. */ const char *probe; - char *buffer = (char *)xmalloc (strlen (base) + 10); + char *buffer = (char *)xmalloc (strlen (base) + 1); char *ptr = buffer; #if HAVE_DOS_BASED_FILE_SYSTEM @@ -2520,6 +2520,9 @@ make_gcov_file_name (const char *input_name, const char *src_name) return result; } +/* Mangle BASE name, copy it at the beginning of PTR buffer and + return address of the \0 character of the buffer. */ + static char * mangle_name (char const *base, char *ptr) { @@ -2527,14 +2530,13 @@ mangle_name (char const *base, char *ptr) /* Generate the source filename part. */ if (!flag_preserve_paths) - { - base = lbasename (base); - len = strlen (base); - memcpy (ptr, base, len); - ptr += len; - } + base = lbasename (base); else - ptr = mangle_path (base); + base = mangle_path (base); + + len = strlen (base); + memcpy (ptr, base, len); + ptr += len; return ptr; } |