Raise error if offset+size is too big
This commit is contained in:
parent
3afcb98657
commit
a1cb7f9efc
1 changed files with 4 additions and 0 deletions
|
@ -464,6 +464,10 @@ cdef Slice slice_transform_callback(void* ctx, const Slice& src) with gil:
|
|||
ret = (<object>ctx).transform(slice_to_bytes(src))
|
||||
offset = ret[0]
|
||||
size = ret[1]
|
||||
if (offset + size) > src.size():
|
||||
msg = "offset(%i) + size(%i) is bigger than slice(%i)"
|
||||
raise Exception(msg % (offset, size, src.size()))
|
||||
|
||||
return Slice(src.data() + offset, size)
|
||||
except Exception as error:
|
||||
print error
|
||||
|
|
Loading…
Reference in a new issue