Skip to content

[io] properly stream TClonesArray with empty slots #17883

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 2 additions & 1 deletion io/io/src/TStreamerInfoActions.cxx
Original file line number Diff line number Diff line change
Expand Up @@ -2491,7 +2491,8 @@ namespace TStreamerInfoActions
static INLINE_TEMPLATE_ARGS Int_t LoopOverCollection(TBuffer &buf, void *start, const void *end, const TConfiguration *config)
{
for(void *iter = start; iter != end; iter = (char*)iter + sizeof(void*) ) {
action(buf, *(void**)iter, config);
if (*(void**)iter)
action(buf, *(void**)iter, config);
}
return 0;
}
Expand Down
21 changes: 21 additions & 0 deletions io/io/test/TBufferFileTests.cxx
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,12 @@

#include "TBufferFile.h"
#include "TClass.h"
#include "TClonesArray.h"
#include "TObjString.h"
#include <vector>
#include <iostream>
#include <iostream>


// Tests ROOT-8367
TEST(TBufferFile, ROOT_8367)
Expand All @@ -26,3 +30,20 @@ TEST(TBufferFile, ROOT_8367)
EXPECT_FLOAT_EQ(v2[6], 7.);
EXPECT_EQ(v2.size(), 7);
}

// https://its.cern.ch/jira/browse/ROOT-6788
TEST(TBufferFile, ROOT_6788)
{
TClonesArray clArray(TObjString::Class(), 100);
for (Int_t i=0; i<28; i++) {
new (clArray[i]) TObjString();
}
TBufferFile buf(TBuffer::kWrite, 10000);
for (Int_t i=0; i<27; i++) {
delete clArray.RemoveAt(i);
}
buf.SetBufferOffset(0);
buf.MapObject(&clArray);
clArray.Streamer(buf);
}

Loading