Skip to content

Commit 9630a30

Browse files
committed
Initialize PortableHostObject::product_
OutputModules can construct the PortableHostObject via the "uninitialized" constructor if no producer produced the data product. Explicit null value for the pointer communicates the absence of data to ROOT.
1 parent 043863c commit 9630a30

File tree

2 files changed

+8
-3
lines changed

2 files changed

+8
-3
lines changed

DataFormats/Portable/interface/PortableHostObject.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -112,7 +112,7 @@ class PortableHostObject {
112112

113113
private:
114114
std::optional<Buffer> buffer_; //!
115-
Product* product_;
115+
Product* product_ = nullptr;
116116
};
117117

118118
#endif // DataFormats_Portable_interface_PortableHostObject_h

DataFormats/Portable/interface/PortableHostObjectReadRules.h

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -33,8 +33,13 @@ static void readPortableHostObject_v1(char *target, TVirtualObject *from_buffer)
3333
// pointer to the Object object being constructed in memory
3434
Object *newObj = (Object *)target;
3535

36-
// move the data from the on-file layout to the newly constructed object
37-
Object::ROOTReadStreamer(newObj, *onfile.product_);
36+
// product_ can be null if the Wrapper<PortableHostObject<T>> was
37+
// default-constructed because a producer did not produce the
38+
// product
39+
if (onfile.product_) {
40+
// move the data from the on-file layout to the newly constructed object
41+
Object::ROOTReadStreamer(newObj, *onfile.product_);
42+
}
3843
}
3944

4045
// put set_PortableHostObject_read_rules in the ROOT namespace to let it forward declare GenerateInitInstance

0 commit comments

Comments
 (0)