From 148070cca4cf7e1b1b7f81835e9ec9991f1895ef Mon Sep 17 00:00:00 2001 From: Jeff Law Date: Thu, 12 Oct 1995 23:26:06 +0000 Subject: * corelow.c (core_open): Don't update the to_sections and to_sections_end fields in core_ops here. It's too late. * irix5-nat.c (solib_add): Update the to_sections and to_sections_end fields in core_ops here if needed. * osfsolib.c (solib_add): Likewise. * rs6000-nat.c (xcoff_reload_core): Likewise. * solib.c (solib_add): Likewise. * somsolib.c (solib_add): Likewise. --- gdb/irix5-nat.c | 15 +++++++++++++++ 1 file changed, 15 insertions(+) (limited to 'gdb/irix5-nat.c') diff --git a/gdb/irix5-nat.c b/gdb/irix5-nat.c index 3bfaef7..3ba00b1 100644 --- a/gdb/irix5-nat.c +++ b/gdb/irix5-nat.c @@ -621,6 +621,13 @@ solib_add (arg_string, from_tty, target) if (count) { + int update_coreops; + + /* We must update the to_sections field in the core_ops structure + here, otherwise we dereference a potential dangling pointer + for each call to target_read/write_memory within this routine. */ + update_coreops = core_ops.to_sections == target->to_sections; + /* Reallocate the target's section table including the new size. */ if (target -> to_sections) { @@ -637,6 +644,14 @@ solib_add (arg_string, from_tty, target) } target -> to_sections_end = target -> to_sections + (count + old); + /* Update the to_sections field in the core_ops structure + if needed. */ + if (update_coreops) + { + core_ops.to_sections = target->to_sections; + core_ops.to_sections_end = target->to_sections_end; + } + /* Add these section table entries to the target's table. */ while ((so = find_solib (so)) != NULL) { -- cgit v1.1