diff options
author | Jakub Jelinek <jakub@redhat.com> | 2013-02-27 08:28:48 +0100 |
---|---|---|
committer | Jakub Jelinek <jakub@gcc.gnu.org> | 2013-02-27 08:28:48 +0100 |
commit | 0fcb564b72f58f8d3fa3351fbad33d32b63697ca (patch) | |
tree | e22ae12d4bb7029d94d5769074842b775d33ab77 /gcc/incpath.c | |
parent | dc3577989d23572bc6f695e791eeaad33cfe8f6a (diff) |
incpath.c (add_standard_paths): Use reconcat instead of concat where appropriate and avoid leaking memory.
* incpath.c (add_standard_paths): Use reconcat instead of concat
where appropriate and avoid leaking memory.
From-SVN: r196306
Diffstat (limited to 'gcc/incpath.c')
-rw-r--r-- | gcc/incpath.c | 31 |
1 files changed, 21 insertions, 10 deletions
diff --git a/gcc/incpath.c b/gcc/incpath.c index 0e61b8b747a..018da982c14 100644 --- a/gcc/incpath.c +++ b/gcc/incpath.c @@ -149,12 +149,17 @@ add_standard_paths (const char *sysroot, const char *iprefix, { char *str = concat (iprefix, p->fname + len, NULL); if (p->multilib == 1 && imultilib) - str = concat (str, dir_separator_str, imultilib, NULL); + str = reconcat (str, str, dir_separator_str, + imultilib, NULL); else if (p->multilib == 2) { if (!imultiarch) - continue; - str = concat (str, dir_separator_str, imultiarch, NULL); + { + free (str); + continue; + } + str = reconcat (str, str, dir_separator_str, + imultiarch, NULL); } add_path (str, SYSTEM, p->cxx_aware, false); } @@ -183,6 +188,7 @@ add_standard_paths (const char *sysroot, const char *iprefix, && !filename_ncmp (p->fname, cpp_PREFIX, cpp_PREFIX_len)) { static const char *relocated_prefix; + char *ostr; /* If this path starts with the configure-time prefix, but the compiler has been relocated, replace it with the run-time prefix. The run-time exec prefix @@ -198,22 +204,27 @@ add_standard_paths (const char *sysroot, const char *iprefix, = make_relative_prefix (dummy, cpp_EXEC_PREFIX, cpp_PREFIX); + free (dummy); } - str = concat (relocated_prefix, - p->fname + cpp_PREFIX_len, - NULL); - str = update_path (str, p->component); + ostr = concat (relocated_prefix, + p->fname + cpp_PREFIX_len, + NULL); + str = update_path (ostr, p->component); + free (ostr); } else str = update_path (p->fname, p->component); if (p->multilib == 1 && imultilib) - str = concat (str, dir_separator_str, imultilib, NULL); + str = reconcat (str, str, dir_separator_str, imultilib, NULL); else if (p->multilib == 2) { if (!imultiarch) - continue; - str = concat (str, dir_separator_str, imultiarch, NULL); + { + free (str); + continue; + } + str = reconcat (str, str, dir_separator_str, imultiarch, NULL); } add_path (str, SYSTEM, p->cxx_aware, false); |