markjm commented on code in PR #3594:
URL: https://github.com/apache/thrift/pull/3594#discussion_r3407586264
##########
lib/py/src/ext/protocol.tcc:
##########
@@ -301,9 +301,17 @@ bool ProtocolBase<Impl>::readBytes(char** output, int len)
{
PyErr_Format(PyExc_ValueError, "attempted to read negative length: %d",
len);
return false;
}
- // TODO(dreiss): Don't fear the malloc. Think about taking a copy of
- // the partial read instead of forcing the transport
- // to prepend it to its buffer.
+
+ if (input_.direct_buf) {
+ if (input_.direct_pos + static_cast<size_t>(len) > input_.direct_size) {
+ PyErr_SetString(PyExc_EOFError, "read past end of buffer");
+ return false;
+ }
+
+ *output = const_cast<char*>(input_.direct_buf + input_.direct_pos);
+ input_.direct_pos += static_cast<size_t>(len);
+ return true;
+ }
Review Comment:
good catch mr bot - fixed
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: [email protected]
For queries about this service, please contact Infrastructure at:
[email protected]