Fix access to uninitialized variable in fill_in_stop_func

Message ID 20190809191313.25200-1-pedromfc@linux.ibm.com
State New, archived
Headers

Commit Message

Pedro Franco de Carvalho Aug. 9, 2019, 7:13 p.m. UTC
  This patch changes find_pc_partial_function so that *block is set to
nullptr when it fails, so that fill_in_stop_func won't access an
uninitialized variable.

gdb/ChangeLog:
YYYY-MM-DD  Pedro Franco de Carvalho  <pedromfc@linux.ibm.com>

	* blockframe.c (find_pc_partial_function): Set *block to nullptr
          when the function fails.
---
 gdb/blockframe.c | 2 ++
 1 file changed, 2 insertions(+)
  

Comments

Kevin Buettner Aug. 9, 2019, 7:17 p.m. UTC | #1
On Fri,  9 Aug 2019 16:13:13 -0300
Pedro Franco de Carvalho <pedromfc@linux.ibm.com> wrote:

> This patch changes find_pc_partial_function so that *block is set to
> nullptr when it fails, so that fill_in_stop_func won't access an
> uninitialized variable.
> 
> gdb/ChangeLog:
> YYYY-MM-DD  Pedro Franco de Carvalho  <pedromfc@linux.ibm.com>
> 
> 	* blockframe.c (find_pc_partial_function): Set *block to nullptr
>           when the function fails.

Okay.

Kevin
  
Pedro Franco de Carvalho Aug. 9, 2019, 7:51 p.m. UTC | #2
Kevin Buettner <kevinb@redhat.com> writes:

> Okay.

Thanks! Pushed.

--
Pedro Franco de Carvalho
  
Tom Tromey Aug. 9, 2019, 8:42 p.m. UTC | #3
>>>>> "Pedro" == Pedro Franco de Carvalho <pedromfc@linux.ibm.com> writes:

Pedro> This patch changes find_pc_partial_function so that *block is set to
Pedro> nullptr when it fails, so that fill_in_stop_func won't access an
Pedro> uninitialized variable.

Pedro> gdb/ChangeLog:
Pedro> YYYY-MM-DD  Pedro Franco de Carvalho  <pedromfc@linux.ibm.com>

Pedro> 	* blockframe.c (find_pc_partial_function): Set *block to nullptr
Pedro>           when the function fails.

Thanks.  This is ok.

Tom
  

Patch

diff --git a/gdb/blockframe.c b/gdb/blockframe.c
index fe7807b87a..4462274f46 100644
--- a/gdb/blockframe.c
+++ b/gdb/blockframe.c
@@ -331,6 +331,8 @@  find_pc_partial_function (CORE_ADDR pc, const char **name, CORE_ADDR *address,
 	*address = 0;
       if (endaddr != NULL)
 	*endaddr = 0;
+      if (block != nullptr)
+	*block = nullptr;
       return 0;
     }