projects
/
deliverable
/
binutils-gdb.git
/ blobdiff
commit
grep
author
committer
pickaxe
?
search:
re
summary
|
shortlog
|
log
|
commit
|
commitdiff
|
tree
raw
|
inline
| side by side
Sync libiberty sources with GCC.
[deliverable/binutils-gdb.git]
/
libiberty
/
make-relative-prefix.c
diff --git
a/libiberty/make-relative-prefix.c
b/libiberty/make-relative-prefix.c
index 7239e7b0bae2d98c8f201775f63ffc4073526647..f74bbdc9038e3c55507d81a3e8abc5ae826c6c6a 100644
(file)
--- a/
libiberty/make-relative-prefix.c
+++ b/
libiberty/make-relative-prefix.c
@@
-1,6
+1,5
@@
/* Relative (relocatable) prefix support.
/* Relative (relocatable) prefix support.
- Copyright (C) 1987, 1989, 1992, 1993, 1994, 1995, 1996, 1997, 1998,
- 1999, 2000, 2001, 2002, 2006, 2012 Free Software Foundation, Inc.
+ Copyright (C) 1987-2017 Free Software Foundation, Inc.
This file is part of libiberty.
This file is part of libiberty.
@@
-233,6
+232,7
@@
make_relative_prefix_1 (const char *progname, const char *bin_prefix,
int i, n, common;
int needed_len;
char *ret = NULL, *ptr, *full_progname;
int i, n, common;
int needed_len;
char *ret = NULL, *ptr, *full_progname;
+ char *alloc_ptr = NULL;
if (progname == NULL || bin_prefix == NULL || prefix == NULL)
return NULL;
if (progname == NULL || bin_prefix == NULL || prefix == NULL)
return NULL;
@@
-248,14
+248,18
@@
make_relative_prefix_1 (const char *progname, const char *bin_prefix,
{
char *startp, *endp, *nstore;
size_t prefixlen = strlen (temp) + 1;
{
char *startp, *endp, *nstore;
size_t prefixlen = strlen (temp) + 1;
+ size_t len;
if (prefixlen < 2)
prefixlen = 2;
if (prefixlen < 2)
prefixlen = 2;
- nstore = (char *) alloca (prefixlen + strlen (progname) + 1
+ len = prefixlen + strlen (progname) + 1;
#ifdef HAVE_HOST_EXECUTABLE_SUFFIX
#ifdef HAVE_HOST_EXECUTABLE_SUFFIX
- + strlen (HOST_EXECUTABLE_SUFFIX)
+ len += strlen (HOST_EXECUTABLE_SUFFIX);
#endif
#endif
- );
+ if (len < MAX_ALLOCA_SIZE)
+ nstore = (char *) alloca (len);
+ else
+ alloc_ptr = nstore = (char *) malloc (len);
startp = endp = temp;
while (1)
startp = endp = temp;
while (1)
@@
-311,12
+315,12
@@
make_relative_prefix_1 (const char *progname, const char *bin_prefix,
else
full_progname = strdup (progname);
if (full_progname == NULL)
else
full_progname = strdup (progname);
if (full_progname == NULL)
-
return NULL
;
+
goto bailout
;
prog_dirs = split_directories (full_progname, &prog_num);
free (full_progname);
if (prog_dirs == NULL)
prog_dirs = split_directories (full_progname, &prog_num);
free (full_progname);
if (prog_dirs == NULL)
-
return NULL
;
+
goto bailout
;
bin_dirs = split_directories (bin_prefix, &bin_num);
if (bin_dirs == NULL)
bin_dirs = split_directories (bin_prefix, &bin_num);
if (bin_dirs == NULL)
@@
-394,6
+398,7
@@
make_relative_prefix_1 (const char *progname, const char *bin_prefix,
free_split_directories (prog_dirs);
free_split_directories (bin_dirs);
free_split_directories (prefix_dirs);
free_split_directories (prog_dirs);
free_split_directories (bin_dirs);
free_split_directories (prefix_dirs);
+ free (alloc_ptr);
return ret;
}
return ret;
}
This page took
0.024393 seconds
and
4
git commands to generate.