Skip to content

Commit

Permalink
python: Raise error when buffer is too small
Browse files Browse the repository at this point in the history
  • Loading branch information
shramov committed Dec 17, 2024
1 parent 0da804e commit e7ed6cd
Showing 1 changed file with 2 additions and 2 deletions.
4 changes: 2 additions & 2 deletions python/tll/scheme.pyx
Original file line number Diff line number Diff line change
Expand Up @@ -782,8 +782,8 @@ cdef pack_bytes(v, dest, tail, tail_offset):
if not isinstance(v, memoryview):
v = memoryview(s2b(v))
cdef Py_buffer * inbuf = PyMemoryView_GET_BUFFER(v)
if buf.len < inbuf.len: return EMSGSIZE
# raise TLLError("Dest buffer too small: {} < {}".format(buf.len, inbuf.len))
if buf.len < inbuf.len:
raise ValueError(f"Dest buffer too small: {buf.len} < {inbuf.len}")
memcpy(buf.buf, inbuf.buf, inbuf.len)
#if inbuf.len < buf.len:
# memset(buf.buf + inbuf.len, 0, buf.len - inbuf.len)
Expand Down

0 comments on commit e7ed6cd

Please sign in to comment.