Skip to content

Commit 8e75aa1

Browse files
committed
Modify CCDB headers check to account for CCDBSerialized<> access of non-CCDB objects
1 parent 260d9da commit 8e75aa1

File tree

1 file changed

+8
-3
lines changed

1 file changed

+8
-3
lines changed

Framework/Core/src/DataRefUtils.cxx

Lines changed: 8 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -93,7 +93,7 @@ void* DataRefUtils::decodeCCDB(DataRef const& ref, std::type_info const& tinfo)
9393
!std::strncmp(buff + dh->payloadSize - sizeof(FlatHeaderAnnot), FlatHeaderAnnot, sizeof(FlatHeaderAnnot))) {
9494
headerSize = *reinterpret_cast<const int*>(buff + dh->payloadSize - Offset);
9595
}
96-
if (headerSize <= 0) {
96+
if (headerSize < 0) {
9797
LOGP(fatal, "Anomalous flattened header size {} extracted", headerSize);
9898
}
9999
TMemFile memFile("name", const_cast<char*>(ref.payload), dh->payloadSize - headerSize, "READ");
@@ -119,16 +119,21 @@ std::map<std::string, std::string> DataRefUtils::extractCCDBHeaders(DataRef cons
119119
constexpr char FlatHeaderAnnot[] = "$HEADER$";
120120
constexpr int Offset = sizeof(int) + sizeof(FlatHeaderAnnot);
121121
int headerSize = 0, ss0 = 0;
122+
std::map<std::string, std::string> res;
122123
if (dh->payloadSize >= Offset && !std::strncmp(buff + dh->payloadSize - sizeof(FlatHeaderAnnot), FlatHeaderAnnot, sizeof(FlatHeaderAnnot))) {
123124
headerSize = *reinterpret_cast<const int*>(buff + dh->payloadSize - Offset);
125+
} else { // header was not added
126+
LOGP(warn, "CCDB headers were not added to condition object blob, returning dummy header map");
127+
return res;
124128
}
125-
if (headerSize <= 0) {
129+
130+
if (headerSize < 0) {
126131
LOGP(fatal, "Anomalous flattened header size {} extracted", headerSize);
127132
}
133+
128134
buff += dh->payloadSize - headerSize; // jump to the start of flattened header
129135
headerSize -= Offset;
130136
const char* str0 = &buff[ss0++];
131-
std::map<std::string, std::string> res;
132137
while (ss0 < headerSize) {
133138
if (buff[ss0++] == 0) {
134139
if (!str0) {

0 commit comments

Comments
 (0)