From 98567efeaaf7ebd167621e56a2bd272c4ec1ebd4 Mon Sep 17 00:00:00 2001 From: JP Smith Date: Mon, 27 Feb 2017 14:25:18 -0600 Subject: [PATCH] Force pc argument to add_hook to be an int or None (#30) * force pc to be an int or None * follow pep8 more closely * change debug message to an error * use format and isinstance --- manticore/manticore.py | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/manticore/manticore.py b/manticore/manticore.py index c7eed2a..4878493 100644 --- a/manticore/manticore.py +++ b/manticore/manticore.py @@ -310,7 +310,10 @@ class Manticore(object): Add a callback to be invoked on executing a program counter. Pass 'None' for pc to invoke callback on every instruction. ''' - self._hooks.setdefault(pc, set()).add(callback) + if not (isinstance(pc, (int, long)) or pc is None): + raise TypeError("pc must be either an int or None, not {}".format(pc.__class__.__name__)) + else: + self._hooks.setdefault(pc, set()).add(callback) def _get_symbol_address(self, symbol): '''