[binutils-gdb] gdb/gcore: check return values of some find_memory_region_ftype calls
Simon Marchi via Gdb-cvs <[email protected]>
| Newsgroups | gmane.comp.gdb.cvs |
|---|---|
| Message-ID | <[email protected]> |
https://sourceware.org/git/gitweb.cgi?p=binutils-gdb.git;h=9f80d0c951819c8f1b2c36027cb196abb12c5f89 commit 9f80d0c951819c8f1b2c36027cb196abb12c5f89 Author: Simon Marchi <[email protected]> Date: Tue Mar 10 13:30:33 2026 -0400 gdb/gcore: check return values of some find_memory_region_ftype calls This fixes some spots that didn't check the return value of a find_memory_region_ftype callback. Change-Id: Ic57933ce76709ca16c93bc66c21da97afb3163a2 Approved-By: Tom Tromey <[email protected]> Diff: --- gdb/gcore.c | 34 ++++++++++++++++++---------------- 1 file changed, 18 insertions(+), 16 deletions(-) diff --git a/gdb/gcore.c b/gdb/gcore.c index 7c6d5f8667f..2bf300c0d29 100644 --- a/gdb/gcore.c +++ b/gdb/gcore.c @@ -558,25 +558,27 @@ objfile_find_memory_regions (struct target_ops *self, } /* Make a stack segment. */ - if (derive_stack_segment (&temp_bottom, &temp_top)) - (*func) (temp_bottom, temp_top - temp_bottom, - true, /* Stack section will be readable. */ - true, /* Stack section will be writable. */ - false, /* Stack section will not be executable. */ - true, /* Stack section will be modified. */ - false, /* No memory tags in the object file. */ - obfd); + if (derive_stack_segment (&temp_bottom, &temp_top) + && !func (temp_bottom, temp_top - temp_bottom, + true, /* Stack section will be readable. */ + true, /* Stack section will be writable. */ + false, /* Stack section will not be executable. */ + true, /* Stack section will be modified. */ + false, /* No memory tags in the object file. */ + obfd)) + return false; /* Make a heap segment. */ if (derive_heap_segment (current_program_space->exec_bfd (), &temp_bottom, - &temp_top)) - (*func) (temp_bottom, temp_top - temp_bottom, - true, /* Heap section will be readable. */ - true, /* Heap section will be writable. */ - false, /* Heap section will not be executable. */ - true, /* Heap section will be modified. */ - false, /* No memory tags in the object file. */ - obfd); + &temp_top) + && !func (temp_bottom, temp_top - temp_bottom, + true, /* Heap section will be readable. */ + true, /* Heap section will be writable. */ + false, /* Heap section will not be executable. */ + true, /* Heap section will be modified. */ + false, /* No memory tags in the object file. */ + obfd)) + return false; return true; }