Commit 4f8e669d authored by Stefan Behnel's avatar Stefan Behnel

off-by-one fix

parent 38cf8831
...@@ -1828,7 +1828,6 @@ class SliceIndexNode(ExprNode): ...@@ -1828,7 +1828,6 @@ class SliceIndexNode(ExprNode):
else: else:
start_offset += '+' start_offset += '+'
if rhs.type.is_array: if rhs.type.is_array:
# FIXME: we should check both array sizes here
array_length = rhs.type.size array_length = rhs.type.size
self.generate_slice_guard_code(code, array_length) self.generate_slice_guard_code(code, array_length)
else: else:
...@@ -1863,10 +1862,10 @@ class SliceIndexNode(ExprNode): ...@@ -1863,10 +1862,10 @@ class SliceIndexNode(ExprNode):
stop = self.stop.result() stop = self.stop.result()
try: try:
stop = int(stop) stop = int(stop)
if stop > 0: if stop < 0:
slice_size = stop
else:
slice_size = self.base.type.size + stop slice_size = self.base.type.size + stop
else:
slice_size = stop
stop = None stop = None
except ValueError: except ValueError:
pass pass
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment