summaryrefslogtreecommitdiff
path: root/gdb/source.c
diff options
context:
space:
mode:
authorJoel Brobecker <brobecker@gnat.com>2010-01-08 13:54:39 +0000
committerJoel Brobecker <brobecker@gnat.com>2010-01-08 13:54:39 +0000
commitd03d81247fede99c83c634a38c36c4764c066628 (patch)
treedf9a37e51b1bdfbd6df8d1ed43112d7ab89375cb /gdb/source.c
parentb39ba57b5fbbb148968e1baf0b15dfcc456c1b1f (diff)
downloadgdb-d03d81247fede99c83c634a38c36c4764c066628.tar.gz
GDB crash with empty executable name (MinGW).
* source.c (openp): Add assert that parameter string is not NULL. if parameter string is an empty string, then return with a failure immediately.
Diffstat (limited to 'gdb/source.c')
-rw-r--r--gdb/source.c14
1 files changed, 14 insertions, 0 deletions
diff --git a/gdb/source.c b/gdb/source.c
index fcfce65a327..20903265716 100644
--- a/gdb/source.c
+++ b/gdb/source.c
@@ -707,6 +707,20 @@ openp (const char *path, int opts, const char *string,
/* The open syscall MODE parameter is not specified. */
gdb_assert ((mode & O_CREAT) == 0);
+ gdb_assert (string != NULL);
+
+ /* A file with an empty name cannot possibly exist. Report a failure
+ without further checking.
+
+ This is an optimization which also defends us against buggy
+ implementations of the "stat" function. For instance, we have
+ noticed that a MinGW debugger built on Windows XP 32bits crashes
+ when the debugger is started with an empty argument. */
+ if (string[0] == '\0')
+ {
+ errno = ENOENT;
+ return -1;
+ }
if (!path)
path = ".";