From a1cb7f9efc40b35e610e266ef1e5e5e4e2d4ef07 Mon Sep 17 00:00:00 2001 From: hofmockel Date: Tue, 21 Jan 2014 17:34:01 +0100 Subject: [PATCH] Raise error if offset+size is too big --- rocksdb/_rocksdb.pyx | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/rocksdb/_rocksdb.pyx b/rocksdb/_rocksdb.pyx index 134cdb3..dfd72db 100644 --- a/rocksdb/_rocksdb.pyx +++ b/rocksdb/_rocksdb.pyx @@ -464,6 +464,10 @@ cdef Slice slice_transform_callback(void* ctx, const Slice& src) with gil: ret = (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