Skip to content

Commit 17aa5dc

Browse files
committed
[test] Add test for #8027
1 parent 436cedd commit 17aa5dc

1 file changed

Lines changed: 25 additions & 0 deletions

File tree

tree/tree/test/TBranch.cxx

Lines changed: 25 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -234,4 +234,29 @@ TEST_F(TBranchTest, branchInheritsCompression)
234234
{
235235
for(int mode = 4; mode >= 0; --mode)
236236
ASSERT_TRUE(nocomp(mode)) << "Failed for mode: " << mode;
237+
}
238+
239+
// Inspired by issue #8027
240+
TEST(TBranchTest, InvalidRead)
241+
{
242+
const char *ofileName = "test_8027.root";
243+
struct PathRAII {
244+
std::string fPath;
245+
PathRAII(const char *path) : fPath(path) {}
246+
~PathRAII() { std::remove(fPath.c_str()); }
247+
};
248+
PathRAII pr(ofileName);
249+
std::unique_ptr<TFile> tf{TFile::Open(ofileName, "RECREATE")};
250+
auto t = new TTree("tree", "tree");
251+
252+
auto f = new TNamed("foo", "bar");
253+
auto b = t->Branch("FileMetaData", &f);
254+
255+
delete f;
256+
f = nullptr;
257+
b->SetAddress(nullptr);
258+
259+
t->Fill();
260+
t->Write();
261+
tf->Close();
237262
}

0 commit comments

Comments
 (0)