From 60f7655a4abc5baa3b8861ff896090dec2c3dcd7 Mon Sep 17 00:00:00 2001 From: Doug Evans Date: Thu, 13 Nov 2014 15:43:12 -0800 Subject: [PATCH] dwarf2read.c (update_enumeration_type_from_children): Avoid infinite loop. gdb/ChangeLog: * dwarf2read.c (update_enumeration_type_from_children): Avoid infinite loop. --- gdb/ChangeLog | 5 +++++ gdb/dwarf2read.c | 8 +++++--- 2 files changed, 10 insertions(+), 3 deletions(-) diff --git a/gdb/ChangeLog b/gdb/ChangeLog index 53b05b4465e..7f918e9ecfe 100644 --- a/gdb/ChangeLog +++ b/gdb/ChangeLog @@ -1,3 +1,8 @@ +2014-11-13 Doug Evans + + * dwarf2read.c (update_enumeration_type_from_children): Avoid + infinite loop. + 2014-11-13 Jan Kratochvil * NEWS (maint set target-async): Fix typo. diff --git a/gdb/dwarf2read.c b/gdb/dwarf2read.c index ce37adfe72e..1250bc7e768 100644 --- a/gdb/dwarf2read.c +++ b/gdb/dwarf2read.c @@ -13231,7 +13231,7 @@ update_enumeration_type_from_children (struct die_info *die, struct dwarf2_cu *cu) { struct obstack obstack; - struct die_info *child_die = die->child; + struct die_info *child_die; int unsigned_enum = 1; int flag_enum = 1; ULONGEST mask = 0; @@ -13240,13 +13240,16 @@ update_enumeration_type_from_children (struct die_info *die, obstack_init (&obstack); old_chain = make_cleanup_obstack_free (&obstack); - while (child_die != NULL && child_die->tag) + for (child_die = die->child; + child_die != NULL && child_die->tag; + child_die = sibling_die (child_die)) { struct attribute *attr; LONGEST value; const gdb_byte *bytes; struct dwarf2_locexpr_baton *baton; const char *name; + if (child_die->tag != DW_TAG_enumerator) continue; @@ -13274,7 +13277,6 @@ update_enumeration_type_from_children (struct die_info *die, a flag type, no need to look at the rest of the enumerates. */ if (!unsigned_enum && !flag_enum) break; - child_die = sibling_die (child_die); } if (unsigned_enum) -- 2.30.2