45 lines
1.3 KiB
Diff
45 lines
1.3 KiB
Diff
From 4e5eaa702d02a7c6170f2d534b323996f1afe06c Mon Sep 17 00:00:00 2001
|
|
From: Jon Turney <jon.turney@dronecode.org.uk>
|
|
Date: Wed, 13 Jan 2016 18:27:48 +0000
|
|
Subject: [PATCH 3/5] Better handling for realpath() failures in
|
|
windows_make_so() on Cygwin
|
|
|
|
Fix a memory leak which would occur in the case when the result of realpath() is
|
|
greater than or equal to SO_NAME_MAX_PATH_SIZE.
|
|
|
|
Distinguish between realpath() failing (returning NULL), and returning a path
|
|
longer than SO_NAME_MAX_PATH_SIZE
|
|
|
|
Warn rather than stopping with an error in those cases.
|
|
|
|
Original patch from Tim Chick. Memory leak fix by Corinna Vinschen.
|
|
---
|
|
gdb/windows-nat.c | 10 ++++++++--
|
|
1 file changed, 8 insertions(+), 2 deletions(-)
|
|
|
|
diff --git a/gdb/windows-nat.c b/gdb/windows-nat.c
|
|
index a0faa058be7..8329e3d0235 100644
|
|
--- a/gdb/windows-nat.c
|
|
+++ b/gdb/windows-nat.c
|
|
@@ -817,9 +817,15 @@ windows_make_so (const char *name, LPVOID load_addr)
|
|
else
|
|
{
|
|
char *rname = realpath (name, NULL);
|
|
- if (rname && strlen (rname) < SO_NAME_MAX_PATH_SIZE)
|
|
+ if (rname)
|
|
{
|
|
- strcpy (so->so_name, rname);
|
|
+ if (strlen (rname) < SO_NAME_MAX_PATH_SIZE)
|
|
+ strcpy (so->so_name, rname);
|
|
+ else
|
|
+ {
|
|
+ warning (_("dll path \"%s\" too long"), rname);
|
|
+ strcpy (so->so_name, so->so_original_name);
|
|
+ }
|
|
free (rname);
|
|
}
|
|
else
|
|
--
|
|
2.31.1.windows.1
|
|
|