You are viewing a plain text version of this content. The canonical link for it is here.
Posted to notifications@thrift.apache.org by "Jens Geyer (Jira)" <ji...@apache.org> on 2026/06/01 21:35:00 UTC
[jira] [Created] (THRIFT-6065) Haxe TMemoryStream cannot be written to (fixed-size buffer, uninitialized Position)
Jens Geyer created THRIFT-6065:
----------------------------------
Summary: Haxe TMemoryStream cannot be written to (fixed-size buffer, uninitialized Position)
Key: THRIFT-6065
URL: https://issues.apache.org/jira/browse/THRIFT-6065
Project: Thrift
Issue Type: Bug
Components: Haxe - Library
Reporter: Jens Geyer
TMemoryStream (lib/haxe/src/org/apache/thrift/transport/TMemoryStream.hx) cannot be written to.
Its Write() does Data.set(Position + i, ...) into a fixed-size Bytes, which cannot grow, so writing to a freshly constructed stream is out of bounds. On the neko target the no-argument constructor never initializes Position, so the first write throws "Invalid operation (+)". Write() also never advances Position, and the constructor leaves Position at the end of any supplied data, so a stream built from existing bytes cannot be read without first resetting Position = 0.
Fix: back the stream with a growable buffer (capacity doubling) so writing past the current end enlarges the backing Bytes and advances Position, track the logical length separately for Read/Peek, and always initialize Position = 0. This lets a single TMemoryStream be used for an in-memory write-then-read round-trip (write, set Position = 0, read), as an alternative to a temporary file via TFileStream.
--
This message was sent by Atlassian Jira
(v8.20.10#820010)