From 3c1102d8fed00b1498c05b7d8162dda9f493ce95 Mon Sep 17 00:00:00 2001 From: Robert Grosse Date: Sat, 31 Dec 2016 15:05:27 -0800 Subject: [PATCH] Ignore Code attributes outside of methods (#110) --- Krakatau/assembler/disassembly.py | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/Krakatau/assembler/disassembly.py b/Krakatau/assembler/disassembly.py index d6911946..fb5f2eda 100644 --- a/Krakatau/assembler/disassembly.py +++ b/Krakatau/assembler/disassembly.py @@ -352,7 +352,7 @@ def method(a, m): a.val('.method'), a.flags(m.access, RFLAGS_M), a.utfref(m.name), a.val(':'), a.utfref(m.desc), a.eol() a.indentlevel += 1 for attr in m.attributes: - a.attribute(attr) + a.attribute(attr, in_method=True) a.indentlevel -= 1 a.val('.end method'), a.eol() @@ -526,7 +526,7 @@ def instruction(a, r): ########################################################################### ### Attributes ############################################################ - def attribute(a, attr): + def attribute(a, attr, in_method=False): name = a.pool.getutf(attr.name) if not a.roundtrip and name in (b'BootstrapMethods', b'StackMapTable'): return @@ -545,7 +545,7 @@ def attribute(a, attr): a.val('.annotationdefault'), a.element_value(r) elif name == b'BootstrapMethods': a.val('.bootstrapmethods') - elif name == b'Code': + elif name == b'Code' and in_method: a.code(r) elif name == b'ConstantValue': a.val('.constantvalue'), a.ldcrhs(r.u16())