[THRIFT-5871] Improve MAX_MESSAGE_SIZE_CHECK and friends
diff --git a/lib/delphi/src/Thrift.Protocol.Compact.pas b/lib/delphi/src/Thrift.Protocol.Compact.pas
index a8ad53a..afb3dd5 100644
--- a/lib/delphi/src/Thrift.Protocol.Compact.pas
+++ b/lib/delphi/src/Thrift.Protocol.Compact.pas
@@ -1011,8 +1011,8 @@
// Return the minimum number of bytes a type will consume on the wire
begin
case aType of
- TType.Stop: result := 0;
- TType.Void: result := 0;
+ TType.Stop: result := 1; // T_STOP needs to count itself
+ TType.Void: result := 1; // T_VOID needs to count itself
TType.Bool_: result := SizeOf(Byte);
TType.Byte_: result := SizeOf(Byte);
TType.Double_: result := 8; // uses fixedLongToBytes() which always writes 8 bytes
@@ -1020,7 +1020,7 @@
TType.I32: result := SizeOf(Byte);
TType.I64: result := SizeOf(Byte);
TType.String_: result := SizeOf(Byte); // string length
- TType.Struct: result := 0; // empty struct
+ TType.Struct: result := 1; // empty struct needs at least 1 byte for the T_STOP
TType.Map: result := SizeOf(Byte); // element count
TType.Set_: result := SizeOf(Byte); // element count
TType.List: result := SizeOf(Byte); // element count
diff --git a/lib/delphi/src/Thrift.Protocol.JSON.pas b/lib/delphi/src/Thrift.Protocol.JSON.pas
index 2a9682c..5be7ae0 100644
--- a/lib/delphi/src/Thrift.Protocol.JSON.pas
+++ b/lib/delphi/src/Thrift.Protocol.JSON.pas
@@ -1257,8 +1257,8 @@
// Return the minimum number of bytes a type will consume on the wire
begin
case aType of
- TType.Stop: result := 0;
- TType.Void: result := 0;
+ TType.Stop: result := 1; // T_STOP needs to count itself
+ TType.Void: result := 1; // T_VOID needs to count itself
TType.Bool_: result := 1;
TType.Byte_: result := 1;
TType.Double_: result := 1;
diff --git a/lib/delphi/src/Thrift.Protocol.pas b/lib/delphi/src/Thrift.Protocol.pas
index 969fbcd..ecf2103 100644
--- a/lib/delphi/src/Thrift.Protocol.pas
+++ b/lib/delphi/src/Thrift.Protocol.pas
@@ -1237,8 +1237,8 @@
// Return the minimum number of bytes a type will consume on the wire
begin
case aType of
- TType.Stop: result := 0;
- TType.Void: result := 0;
+ TType.Stop: result := 1; // T_STOP needs to count itself
+ TType.Void: result := 1; // T_VOID needs to count itself
TType.Bool_: result := SizeOf(Byte);
TType.Byte_: result := SizeOf(Byte);
TType.Double_: result := SizeOf(Double);
@@ -1246,7 +1246,7 @@
TType.I32: result := SizeOf(Int32);
TType.I64: result := SizeOf(Int64);
TType.String_: result := SizeOf(Int32); // string length
- TType.Struct: result := 0; // empty struct
+ TType.Struct: result := 1; // empty struct needs at least 1 byte for the T_STOP
TType.Map: result := SizeOf(Int32); // element count
TType.Set_: result := SizeOf(Int32); // element count
TType.List: result := SizeOf(Int32); // element count