From 7cb2be0010f872e988a79c3ea1da7398e4702ca1 Mon Sep 17 00:00:00 2001 From: Danilo Piparo Date: Sun, 26 Jul 2026 18:36:18 +0200 Subject: [PATCH] [test] Add test for #8027 --- tree/tree/test/TBranch.cxx | 25 +++++++++++++++++++++++++ 1 file changed, 25 insertions(+) diff --git a/tree/tree/test/TBranch.cxx b/tree/tree/test/TBranch.cxx index 5290046098c77..04c2c1b261c41 100644 --- a/tree/tree/test/TBranch.cxx +++ b/tree/tree/test/TBranch.cxx @@ -234,4 +234,29 @@ TEST_F(TBranchTest, branchInheritsCompression) { for(int mode = 4; mode >= 0; --mode) ASSERT_TRUE(nocomp(mode)) << "Failed for mode: " << mode; +} + +// Inspired by issue #8027 +TEST(Regression, InvalidRead) +{ + const char *ofileName = "test_8027.root"; + struct PathRAII { + std::string fPath; + PathRAII(const char *path) : fPath(path) {} + ~PathRAII() { std::remove(fPath.c_str()); } + }; + PathRAII pr(ofileName); + std::unique_ptr tf{TFile::Open(ofileName, "RECREATE")}; + auto t = new TTree("tree", "tree"); + + auto f = new TNamed("foo", "bar"); + auto b = t->Branch("FileMetaData", &f); + + delete f; + f = nullptr; + b->SetAddress(nullptr); + + t->Fill(); + t->Write(); + tf->Close(); } \ No newline at end of file