2008-11-22 Jan Kratochvil Fix double free on error inserting the breakpoint instruction. * breakpoint.c (create_breakpoints): Move the update_global_location_list call to ... (break_command_really): ... here together with the second local call both unified after all the cleanups. --- gdb/breakpoint.c 22 Nov 2008 04:41:45 -0000 1.362 +++ gdb/breakpoint.c 22 Nov 2008 20:10:07 -0000 @@ -5257,8 +5257,6 @@ create_breakpoints (struct symtabs_and_l cond_string, type, disposition, thread, ignore_count, ops, from_tty); } - - update_global_location_list (1); } /* Parse ARG which is assumed to be a SAL specification possibly @@ -5579,7 +5577,6 @@ break_command_really (char *arg, char *c b->condition_not_parsed = 1; b->ops = ops; - update_global_location_list (1); mention (b); } @@ -5591,6 +5588,11 @@ break_command_really (char *arg, char *c discard_cleanups (breakpoint_chain); /* But cleanup everything else. */ do_cleanups (old_chain); + + /* Have already BREAKPOINT_CHAIN discarded as we may get an exception while + inserting the breakpoints which would double-free the resources both by + BREAKPOINT_CHAIN now and during DELETE_BREAKPOINT in the future. */ + update_global_location_list (1); } /* Set a breakpoint.