about summary refs log tree commit diff stats
path: root/miasm2/jitter/codegen.py
diff options
context:
space:
mode:
authorAjax <commial@gmail.com>2016-10-04 10:26:10 +0200
committerAjax <commial@gmail.com>2016-10-04 14:04:30 +0200
commit5813b4c45c296aa3ef16f17c282624d3c8ca31bd (patch)
treee02930f4a7ad1fe53a9914f9a1129f53bf2dcc9e /miasm2/jitter/codegen.py
parentcc27435675802a5967df638b05fe87bd5d9fdd64 (diff)
downloadmiasm-5813b4c45c296aa3ef16f17c282624d3c8ca31bd.tar.gz
miasm-5813b4c45c296aa3ef16f17c282624d3c8ca31bd.zip
Avoid duplicate -1 case
Diffstat (limited to 'miasm2/jitter/codegen.py')
-rw-r--r--miasm2/jitter/codegen.py11
1 files changed, 10 insertions, 1 deletions
diff --git a/miasm2/jitter/codegen.py b/miasm2/jitter/codegen.py
index 540509bf..1ce7ba6d 100644
--- a/miasm2/jitter/codegen.py
+++ b/miasm2/jitter/codegen.py
@@ -370,14 +370,23 @@ class CGen(object):
 
         @attrib: an Attributs instance
         @instr_offsets: list of instructions offsets
-        @dst2index: link from dstination to index
+        @dst2index: link from destination to index
         """
 
         if not dst2index:
             return []
         out = []
         out.append('switch(DST_case) {')
+
+        stopcase = False
         for dst, index in sorted(dst2index.iteritems(), key=lambda lblindex: lblindex[1]):
+            if index == -1:
+                # Handle '-1' case only once
+                if not stopcase:
+                    stopcase = True
+                else:
+                    continue
+
             out.append('\tcase %d:' % index)
             out += self.gen_goto_code(attrib, instr_offsets, dst)
             out.append('\t\tbreak;')