Skip to content

Commit

Permalink
Fix bug in address calculation.
Browse files Browse the repository at this point in the history
  • Loading branch information
mkskeller committed Mar 28, 2024
1 parent bd1a3cb commit 2250107
Showing 1 changed file with 5 additions and 3 deletions.
8 changes: 5 additions & 3 deletions Compiler/types.py
Original file line number Diff line number Diff line change
Expand Up @@ -5770,6 +5770,8 @@ def get_address(self, index, size=None):
if isinstance(index, (_secret, _single)):
raise CompilerError('need cleartext index')
key = str(index), size or 1
if not util.is_constant(index):
index = regint.conv(index)
if self.length is not None:
from .GC.types import cbits
if isinstance(index, int):
Expand All @@ -5778,9 +5780,9 @@ def get_address(self, index, size=None):
raise IndexError('index %s, length %s' % \
(str(index), str(self.length)))
elif self.check_indices and not isinstance(index, cbits):
library.runtime_error_if(regint.conv(index) >= self.length,
'overflow: %s/%s',
index, self.length)
library.runtime_error_if(
(index >= self.length).bit_or(index < 0),
'overflow: %s/%s', index, self.length)
if (program.curr_block, key) not in self.address_cache:
n = self.value_type.n_elements()
length = self.length
Expand Down

0 comments on commit 2250107

Please sign in to comment.