diff options
| author | serpilliere <serpilliere@users.noreply.github.com> | 2016-01-30 23:47:58 +0100 |
|---|---|---|
| committer | serpilliere <serpilliere@users.noreply.github.com> | 2016-01-30 23:47:58 +0100 |
| commit | d21a47392556f9b20241aa70d3e1e7151d56e34f (patch) | |
| tree | bd6002a816a67d9f74434b62df675c36c4e538c2 | |
| parent | 3672de7c319f39273cb7e34797cb928f424ff7c4 (diff) | |
| parent | 9b6c327d81ded9eb777130d7a4efb1dbe8a78c77 (diff) | |
| download | miasm-d21a47392556f9b20241aa70d3e1e7151d56e34f.tar.gz miasm-d21a47392556f9b20241aa70d3e1e7151d56e34f.zip | |
Merge pull request #315 from commial/dangerous-default-value
Fix dangerous-default-value
| -rw-r--r-- | miasm2/analysis/sandbox.py | 4 | ||||
| -rw-r--r-- | miasm2/core/asmbloc.py | 25 | ||||
| -rw-r--r-- | miasm2/ir/ir.py | 10 |
3 files changed, 28 insertions, 11 deletions
diff --git a/miasm2/analysis/sandbox.py b/miasm2/analysis/sandbox.py index 115fd521..61de65a7 100644 --- a/miasm2/analysis/sandbox.py +++ b/miasm2/analysis/sandbox.py @@ -33,7 +33,7 @@ class Sandbox(object): classes = property(lambda x: x.__class__._classes_()) - def __init__(self, fname, options, custom_methods={}, **kwargs): + def __init__(self, fname, options, custom_methods=None, **kwargs): """ Initialize a sandbox @fname: str file name @@ -44,6 +44,8 @@ class Sandbox(object): # Initialize self.fname = fname self.options = options + if custom_methods is None: + custom_methods = {} for cls in self.classes: if cls == Sandbox: continue diff --git a/miasm2/core/asmbloc.py b/miasm2/core/asmbloc.py index 38d3d17a..a6584602 100644 --- a/miasm2/core/asmbloc.py +++ b/miasm2/core/asmbloc.py @@ -411,11 +411,16 @@ class asm_symbol_pool: def dis_bloc(mnemo, pool_bin, label, offset, job_done, symbol_pool, - dont_dis=[], split_dis=[ - ], follow_call=False, dontdis_retcall=False, lines_wd=None, - dis_bloc_callback=None, dont_dis_nulstart_bloc=False, - attrib={}): + dont_dis=None, split_dis=None, follow_call=False, + dontdis_retcall=False, lines_wd=None, dis_bloc_callback=None, + dont_dis_nulstart_bloc=False, attrib=None): # pool_bin.offset = offset + if dont_dis is None: + dont_dis = [] + if split_dis is None: + split_dis = [] + if attrib is None: + attrib = {} lines_cpt = 0 in_delayslot = False delayslot_count = mnemo.delayslot @@ -538,12 +543,18 @@ def dis_bloc(mnemo, pool_bin, label, offset, job_done, symbol_pool, return cur_block, offsets_to_dis -def dis_bloc_all(mnemo, pool_bin, offset, job_done, symbol_pool, dont_dis=[], - split_dis=[], follow_call=False, dontdis_retcall=False, +def dis_bloc_all(mnemo, pool_bin, offset, job_done, symbol_pool, dont_dis=None, + split_dis=None, follow_call=False, dontdis_retcall=False, blocs_wd=None, lines_wd=None, blocs=None, dis_bloc_callback=None, dont_dis_nulstart_bloc=False, - attrib={}): + attrib=None): log_asmbloc.info("dis bloc all") + if dont_dis is None: + dont_dis = [] + if split_dis is None: + split_dis = [] + if attrib is None: + attrib = {} if blocs is None: blocs = AsmCFG() todo = [offset] diff --git a/miasm2/ir/ir.py b/miasm2/ir/ir.py index 122ce6d0..14acb907 100644 --- a/miasm2/ir/ir.py +++ b/miasm2/ir/ir.py @@ -30,8 +30,10 @@ from miasm2.core.graph import DiGraph class irbloc(object): - def __init__(self, label, irs, lines=[]): + def __init__(self, label, irs, lines=None): assert(isinstance(label, asm_label)) + if lines is None: + lines = [] self.label = label self.irs = irs self.lines = lines @@ -133,7 +135,7 @@ class DiGraphIR(DiGraph): def node2lines(self, node): yield self.DotCellDescription(text=str(node.name), attr={'align': 'center', - 'colspan': 2, + 'colspan': 2, 'bgcolor': 'grey'}) if node not in self._blocks: yield [self.DotCellDescription(text="NOT PRESENT", attr={})] @@ -384,11 +386,13 @@ class ir(object): for i, l in enumerate(irs): irs[i] = l.replace_expr(rep) - def get_rw(self, regs_ids=[]): + def get_rw(self, regs_ids=None): """ Calls get_rw(irb) for each bloc @regs_ids : ids of registers used in IR """ + if regs_ids is None: + regs_ids = [] for b in self.blocs.values(): b.get_rw(regs_ids) |