Skip to content

Commit 47ef616

Browse files
committed
io: 64bit bytecount fix for Array and TString.
TString::WriteString was missing the push of the start position on top the stack (necessary as the pop is unconditional in SetByteCount). The startpos in TArray::ReadArray and TString::ReadString can become ULong64_t without any issue. If the length happens to be the same value as the 32bits marker () then it will be 'also' found on the stack Same update for the (reading part of) TContainerConverters.cxx.
1 parent cf49825 commit 47ef616

3 files changed

Lines changed: 7 additions & 8 deletions

File tree

core/base/src/TString.cxx

Lines changed: 5 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1373,7 +1373,7 @@ TString *TString::ReadString(TBuffer &b, const TClass *clReq)
13731373
b.InitMap();
13741374

13751375
// Before reading object save start position
1376-
UInt_t startpos = UInt_t(b.Length());
1376+
ULong64_t startpos = ULong64_t(b.Length());
13771377

13781378
ULong64_t tag;
13791379
TClass *clRef = b.ReadClass(clReq, &tag);
@@ -1444,17 +1444,16 @@ void TString::WriteString(TBuffer &b, const TString *a)
14441444

14451445
} else {
14461446

1447+
TClass *cl = a->IsA();
1448+
14471449
// Reserve space for leading byte count
1448-
UInt_t cntpos = UInt_t(b.Length());
1449-
b.SetBufferOffset(Int_t(cntpos+sizeof(UInt_t)));
1450+
TBuffer::ByteCountWriter bcnt(b, cl);
14501451

1451-
TClass *cl = a->IsA();
14521452
b.WriteClass(cl);
14531453

14541454
((TString *)a)->Streamer(b);
14551455

1456-
// Write byte count
1457-
b.SetByteCount(cntpos);
1456+
// The byte count is written automatically by the ByteCountWriter destructor
14581457
}
14591458
}
14601459

core/cont/src/TArray.cxx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -45,7 +45,7 @@ TArray *TArray::ReadArray(TBuffer &b, const TClass *clReq)
4545
b.InitMap();
4646

4747
// Before reading object save start position
48-
UInt_t startpos = UInt_t(b.Length());
48+
ULong64_t startpos = ULong64_t(b.Length());
4949

5050
ULong64_t tag;
5151
TClass *clRef = b.ReadClass(clReq, &tag);

io/io/src/TContainerConverters.cxx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -102,7 +102,7 @@ void TConvertClonesArrayToProxy::operator()(TBuffer &b, void *pmember, Int_t siz
102102
b.InitMap();
103103

104104
// before reading object save start position
105-
UInt_t startpos = b.Length();
105+
ULong64_t startpos = b.Length();
106106

107107
// attempt to load next object as TClass clCast
108108
ULong64_t tag; // either tag or byte count

0 commit comments

Comments
 (0)