From: Daniel Starke <daniel-email@gmx.net>
To: gdb-patches@sourceware.org
Cc: Daniel Starke <daniel-email@gmx.net>
Subject: [PATCH 1/1] gdb: Fix null pointer dereference on missing PATH variable
Date: Tue, 4 Mar 2025 22:50:11 +0100 [thread overview]
Message-ID: <20250304215011.2092-1-daniel-email@gmx.net> (raw)
When running "show" with missing PATH variable a null pointer is being
dereferenced in path_info().
path_command() correctly checks whether PATH has been set before using it.
It then calls path_info() which retrieves the variable again but fails to
perform the null pointer test on it. As a result, the application crashes with
SIGSEGV on Windows for example.
Fix this by handling the null pointer case in path_info() accordingly.
Signed-off-by: Daniel Starke <daniel-email@gmx.net>
---
gdb/infcmd.c | 5 ++++-
1 file changed, 4 insertions(+), 1 deletion(-)
diff --git a/gdb/infcmd.c b/gdb/infcmd.c
index 00703e44b7b..adb2592ae8e 100644
--- a/gdb/infcmd.c
+++ b/gdb/infcmd.c
@@ -2116,7 +2116,10 @@ static void
path_info (const char *args, int from_tty)
{
gdb_puts ("Executable and object file path: ");
- gdb_puts (current_inferior ()->environment.get (path_var_name));
+ const char *env = current_inferior ()->environment.get (path_var_name);
+ if (!env)
+ env = "";
+ gdb_puts (env);
gdb_puts ("\n");
}
--
2.39.5
next reply other threads:[~2025-03-04 21:51 UTC|newest]
Thread overview: 5+ messages / expand[flat|nested] mbox.gz Atom feed top
2025-03-04 21:50 Daniel Starke [this message]
2025-03-05 3:38 ` Simon Marchi
2025-03-05 15:28 ` Tom Tromey
2025-03-05 15:51 ` Simon Marchi
2025-03-05 16:17 ` daniel-email
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20250304215011.2092-1-daniel-email@gmx.net \
--to=daniel-email@gmx.net \
--cc=gdb-patches@sourceware.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox