diff options
author | Tom Tromey <tromey@redhat.com> | 2014-03-17 19:02:13 +0000 |
---|---|---|
committer | Pedro Alves <palves@redhat.com> | 2014-03-17 19:02:13 +0000 |
commit | 9c1fcd01cf4f222b7065af353cedc3f9701c739c (patch) | |
tree | cb364f30535f0a492c3155874076c11087648e91 /gdb/ui-out.c | |
parent | c712f1e3f711d0f3b694cdfcf4a965d8419fde94 (diff) | |
download | gdb-9c1fcd01cf4f222b7065af353cedc3f9701c739c.zip gdb-9c1fcd01cf4f222b7065af353cedc3f9701c739c.tar.gz gdb-9c1fcd01cf4f222b7065af353cedc3f9701c739c.tar.bz2 |
fix latent bugs in ui-out.c
The destructor code in ui-out.c has a latent bug, which is hidden by
the fact that nothing uses this right now. This patch fixes the
problem. The bug is that we don't always clear a pointer in the
ui-out object, leading to a bad free.
2014-03-17 Tom Tromey <tromey@redhat.com>
* ui-out.c (clear_table, ui_out_new): Clear uiout->table.id.
Diffstat (limited to 'gdb/ui-out.c')
-rw-r--r-- | gdb/ui-out.c | 5 |
1 files changed, 3 insertions, 2 deletions
diff --git a/gdb/ui-out.c b/gdb/ui-out.c index 2edb140..63cbc6e 100644 --- a/gdb/ui-out.c +++ b/gdb/ui-out.c @@ -807,8 +807,8 @@ uo_table_header (struct ui_out *uiout, int width, enum ui_align align, static void clear_table (struct ui_out *uiout) { - if (uiout->table.id) - xfree (uiout->table.id); + xfree (uiout->table.id); + uiout->table.id = NULL; clear_header_list (uiout); } @@ -1114,6 +1114,7 @@ ui_out_new (const struct ui_out_impl *impl, void *data, current->field_count = 0; VEC_safe_push (ui_out_level_p, uiout->levels, current); + uiout->table.id = NULL; uiout->table.header_first = NULL; uiout->table.header_last = NULL; uiout->table.header_next = NULL; |