From: Luis Machado <lgustavo@codesourcery.com>
To: <gdb-patches@sourceware.org>
Subject: [PATCH] Fix obvious gotcha in string comparison
Date: Mon, 24 Oct 2016 21:52:00 -0000 [thread overview]
Message-ID: <1477345919-32239-1-git-send-email-lgustavo@codesourcery.com> (raw)
This patch fixes a gotcha when comparing exception's messages in
exception_print_same. It should've used the statically-allocated
string versions msg1 and msg2 instead.
As is, it could lead to crashes.
gdb/ChangeLog:
2016-10-24 Luis Machado <lgustavo@codesourcery.com>
* exec.c (exception_print_same): Fix string comparison to use
statically-allocated ones.
---
gdb/ChangeLog | 5 +++++
gdb/exec.c | 2 +-
2 files changed, 6 insertions(+), 1 deletion(-)
diff --git a/gdb/ChangeLog b/gdb/ChangeLog
index be72369..388cc1f 100644
--- a/gdb/ChangeLog
+++ b/gdb/ChangeLog
@@ -1,3 +1,8 @@
+2016-10-24 Luis Machado <lgustavo@codesourcery.com>
+
+ * exec.c (exception_print_same): Fix string comparison to use
+ statically-allocated ones.
+
2016-10-21 Tom Tromey <tom@tromey.com>
* dwarf2expr.h (class dwarf_expr_context)
diff --git a/gdb/exec.c b/gdb/exec.c
index d858e99..67ecc63 100644
--- a/gdb/exec.c
+++ b/gdb/exec.c
@@ -152,7 +152,7 @@ exception_print_same (struct gdb_exception e1, struct gdb_exception e2)
return (e1.reason == e2.reason
&& e1.error == e2.error
- && strcmp (e1.message, e2.message) == 0);
+ && strcmp (msg1, msg2) == 0);
}
/* See gdbcore.h. */
--
2.7.4
next reply other threads:[~2016-10-24 21:52 UTC|newest]
Thread overview: 3+ messages / expand[flat|nested] mbox.gz Atom feed top
2016-10-24 21:52 Luis Machado [this message]
2016-10-24 22:25 ` Pedro Alves
2016-10-24 22:46 ` Luis Machado
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=1477345919-32239-1-git-send-email-lgustavo@codesourcery.com \
--to=lgustavo@codesourcery.com \
--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