From 113c31a26d7310293361a68ecd52726bd7f427be Mon Sep 17 00:00:00 2001 From: Graydon Hoare Date: Fri, 2 Jul 2010 08:16:04 -0700 Subject: [PATCH] Trap missing attr forms during dwarf-scan and shut down dwarf reader, don't crash. --- src/rt/rust_crate_reader.cpp | 14 ++++++++++---- 1 file changed, 10 insertions(+), 4 deletions(-) diff --git a/src/rt/rust_crate_reader.cpp b/src/rt/rust_crate_reader.cpp index ece0281c5d9..fc934b983fb 100644 --- a/src/rt/rust_crate_reader.cpp +++ b/src/rt/rust_crate_reader.cpp @@ -258,10 +258,16 @@ rust_crate_reader::die::die(die_reader *rdr, uintptr_t off) dom->get_log().outdent(); } else { ab = rdr->abbrevs.get_abbrev(ab_idx); - dom->log(rust_log::DWARF, "DIE <0x%" PRIxPTR "> abbrev 0x%" - PRIxPTR, off, ab_idx); - dom->log(rust_log::DWARF, " tag 0x%x, has children: %d", - ab->tag, ab->has_children); + if (!ab) { + dom->log(rust_log::DWARF, " bad abbrev number: 0x%" + PRIxPTR, ab_idx); + rdr->fail(); + } else { + dom->log(rust_log::DWARF, "DIE <0x%" PRIxPTR "> abbrev 0x%" + PRIxPTR, off, ab_idx); + dom->log(rust_log::DWARF, " tag 0x%x, has children: %d", + ab->tag, ab->has_children); + } } }