Commits

Benoît Allard committed 826d8fc

stableswitch: parameters are signed

  • Participants
  • Parent commits 7a824f8

Comments (0)

Files changed (2)

File caprunner/interpreter/__init__.py

     def stableswitch(self, default, low, high, *offsets):
         index = self.frame.pop()
         try:
-            return utils.signed2(offsets[index - low])
+            return utils.signed2(offsets[index - utils.signed2(low)])
         except IndexError:
             return utils.signed2(default)
 

File caprunner/utils.py

     return signed(value, 1)
 
 def signed2(value):
+    """
+    >>> signed2(0xffff)
+    -1
+    """
     return signed(value, 2)
 
 def signed4(value):