This is the mail archive of the
gdb-patches@sourceware.org
mailing list for the GDB project.
[PATCH] Fix access to uninitialized variable in fill_in_stop_func
- From: Pedro Franco de Carvalho <pedromfc at linux dot ibm dot com>
- To: gdb-patches at sourceware dot org
- Cc: kevinb at redhat dot com
- Date: Thu, 8 Aug 2019 10:54:43 -0300
- Subject: [PATCH] Fix access to uninitialized variable in fill_in_stop_func
This patch changes fill_in_stop_func to check the return value of
find_pc_partial_function before accessing the block pointer that is only
written by find_pc_partial_function if it returns a success status.
gdb/ChangeLog:
YYYY-MM-DD Pedro Franco de Carvalho <pedromfc@linux.ibm.com>
* infrun.c (fill_in_stop_func): Use return value of
find_pc_partial_function, remove comment.
---
gdb/infrun.c | 15 +++++++--------
1 file changed, 7 insertions(+), 8 deletions(-)
diff --git a/gdb/infrun.c b/gdb/infrun.c
index a9588f896a..15c778c7f3 100644
--- a/gdb/infrun.c
+++ b/gdb/infrun.c
@@ -4117,13 +4117,12 @@ fill_in_stop_func (struct gdbarch *gdbarch,
{
const block *block;
- /* Don't care about return value; stop_func_start and stop_func_name
- will both be 0 if it doesn't work. */
- find_pc_partial_function (ecs->event_thread->suspend.stop_pc,
- &ecs->stop_func_name,
- &ecs->stop_func_start,
- &ecs->stop_func_end,
- &block);
+ bool status = (find_pc_partial_function
+ (ecs->event_thread->suspend.stop_pc,
+ &ecs->stop_func_name,
+ &ecs->stop_func_start,
+ &ecs->stop_func_end,
+ &block));
/* The call to find_pc_partial_function, above, will set
stop_func_start and stop_func_end to the start and end
@@ -4133,7 +4132,7 @@ fill_in_stop_func (struct gdbarch *gdbarch,
the function's start offset and entrypoint. Note that
stop_func_start is NOT advanced when in a range of a
non-contiguous block that does not contain the entry pc. */
- if (block != nullptr
+ if (status && block != nullptr
&& ecs->stop_func_start <= BLOCK_ENTRY_PC (block)
&& BLOCK_ENTRY_PC (block) < ecs->stop_func_end)
{
--
2.20.1