[prev in list] [next in list] [prev in thread] [next in thread] 

List:       gdb-cvs
Subject:    [binutils-gdb] gdbserver, linux-low: add a couple of nullptr assertions.
From:       Felix Willgerodt via Gdb-cvs <gdb-cvs () sourceware ! org>
Date:       2023-08-30 6:39:08
Message-ID: 20230830063908.112BA3858D28 () sourceware ! org
[Download RAW message or body]

https://sourceware.org/git/gitweb.cgi?p=binutils-gdb.git;h=59487af3c8490bc5961d330bc0ef4d5f05ecdc59

commit 59487af3c8490bc5961d330bc0ef4d5f05ecdc59
Author: Willgerodt, Felix <felix.willgerodt@intel.com>
Date:   Tue Aug 29 13:28:04 2023 +0000

    gdbserver, linux-low: add a couple of nullptr assertions.
    
    This safeguards a couple of places that may theoretically return NULL but
    must not in this specific context.  These were found by a static analysis tool.
    
    Approved-By: Tom Tromey <tom@tromey.com>

Diff:
---
 gdbserver/linux-low.cc | 4 ++++
 1 file changed, 4 insertions(+)

diff --git a/gdbserver/linux-low.cc b/gdbserver/linux-low.cc
index e1806ade82f..40b6a907ad9 100644
--- a/gdbserver/linux-low.cc
+++ b/gdbserver/linux-low.cc
@@ -1169,6 +1169,7 @@ linux_process_target::attach (unsigned long pid)
   /* Don't ignore the initial SIGSTOP if we just attached to this
      process.  It will be collected by wait shortly.  */
   initial_thread = find_thread_ptid (ptid_t (pid, pid));
+  gdb_assert (initial_thread != nullptr);
   initial_thread->last_resume_kind = resume_stop;
 
   /* We must attach to every LWP.  If /proc is mounted, use that to
@@ -1198,6 +1199,7 @@ linux_process_target::attach (unsigned long pid)
       gdb_assert (lwpid > 0);
 
       lwp = find_lwp_pid (ptid_t (lwpid));
+      gdb_assert (lwp != nullptr);
 
       if (!WIFSTOPPED (wstat) || WSTOPSIG (wstat) != SIGSTOP)
 	{
@@ -1572,6 +1574,7 @@ linux_process_target::detach (process_info *process)
     });
 
   main_lwp = find_lwp_pid (ptid_t (process->pid));
+  gdb_assert (main_lwp != nullptr);
   detach_one_lwp (main_lwp);
 
   mourn (process);
@@ -2512,6 +2515,7 @@ linux_process_target::wait_for_event_filtered (ptid_t wait_ptid,
   else if (filter_ptid != null_ptid)
     {
       requested_child = find_lwp_pid (filter_ptid);
+      gdb_assert (requested_child != nullptr);
 
       if (stopping_threads == NOT_STOPPING_THREADS
 	  && requested_child->status_pending_p
[prev in list] [next in list] [prev in thread] [next in thread] 

Configure | About | News | Add a list | Sponsored by KoreLogic