aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorKevin Buettner <kevinb@redhat.com>2000-11-21 09:23:32 +0000
committerKevin Buettner <kevinb@redhat.com>2000-11-21 09:23:32 +0000
commita7ec76fe2fc785f39a3c8e6e6cc23d433c4aae77 (patch)
treec9cb84f98f689f0ba93345a6d1d23a37ab30cc89
parenteb6e10cb73e319a8d4651df7df667cd14b26ec70 (diff)
downloadgdb-a7ec76fe2fc785f39a3c8e6e6cc23d433c4aae77.zip
gdb-a7ec76fe2fc785f39a3c8e6e6cc23d433c4aae77.tar.gz
gdb-a7ec76fe2fc785f39a3c8e6e6cc23d433c4aae77.tar.bz2
* solib.c (solib_open): Handle the case where
solib_absolute_prefix is NULL.
-rw-r--r--gdb/ChangeLog5
-rw-r--r--gdb/solib.c28
2 files changed, 21 insertions, 12 deletions
diff --git a/gdb/ChangeLog b/gdb/ChangeLog
index 491bc53..cd38b95 100644
--- a/gdb/ChangeLog
+++ b/gdb/ChangeLog
@@ -1,3 +1,8 @@
+2000-11-21 Kevin Buettner <kevinb@redhat.com>
+
+ * solib.c (solib_open): Handle the case where
+ solib_absolute_prefix is NULL.
+
2000-11-20 Michael Snyder <msnyder@cleaver.cygnus.com>
* solist.h: Declare new function solib_open.
diff --git a/gdb/solib.c b/gdb/solib.c
index 5c982e2..288a54a 100644
--- a/gdb/solib.c
+++ b/gdb/solib.c
@@ -100,21 +100,25 @@ solib_open (char *in_pathname, char **found_pathname)
int found_file = -1;
char *temp_pathname = NULL;
- if (solib_absolute_prefix != NULL &&
- ROOTED_P (in_pathname))
+ if (ROOTED_P (in_pathname))
{
- int prefix_len = strlen (solib_absolute_prefix);
+ if (solib_absolute_prefix == NULL)
+ temp_pathname = in_pathname;
+ else
+ {
+ int prefix_len = strlen (solib_absolute_prefix);
- /* Remove trailing slashes from absolute prefix. */
- while (prefix_len > 0 && SLASH_P (solib_absolute_prefix[prefix_len - 1]))
- prefix_len--;
+ /* Remove trailing slashes from absolute prefix. */
+ while (prefix_len > 0 && SLASH_P (solib_absolute_prefix[prefix_len - 1]))
+ prefix_len--;
- /* Cat the prefixed pathname together. */
- temp_pathname = alloca (prefix_len + strlen (in_pathname) + 1);
- strncpy (temp_pathname, solib_absolute_prefix, prefix_len);
- temp_pathname[prefix_len] = '\0';
- strcat (temp_pathname, in_pathname);
+ /* Cat the prefixed pathname together. */
+ temp_pathname = alloca (prefix_len + strlen (in_pathname) + 1);
+ strncpy (temp_pathname, solib_absolute_prefix, prefix_len);
+ temp_pathname[prefix_len] = '\0';
+ strcat (temp_pathname, in_pathname);
+ }
/* Now see if we can open it. */
found_file = open (temp_pathname, O_RDONLY, 0);
}
@@ -137,7 +141,7 @@ solib_open (char *in_pathname, char **found_pathname)
/* Done. If not found, tough luck. Return found_file and
(optionally) found_pathname. */
- if (found_pathname != NULL)
+ if (found_pathname != NULL && temp_pathname != NULL)
*found_pathname = strsave (temp_pathname);
return found_file;
}