Skip to content

Commit d52ff3c

Browse files
committed
Propagate bulk read errors
1 parent 31f5f10 commit d52ff3c

1 file changed

Lines changed: 14 additions & 0 deletions

File tree

Framework/AnalysisSupport/src/TTreePlugin.cxx

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -211,6 +211,9 @@ auto readBoolValues = [](uint8_t* target, ReadOps& op, TBufferFile& rootBuffer)
211211
while (readEntries < op.rootBranchEntries) {
212212
auto beginValue = readEntries;
213213
readLast = op.branch->GetBulkRead().GetBulkEntries(readEntries, rootBuffer);
214+
if (readLast < 0) {
215+
throw runtime_error_f("Error while reading branch %s starting from %d.", op.branch->GetName(), readEntries);
216+
}
214217
int size = readLast * op.listSize;
215218
readEntries += readLast;
216219
for (int i = beginValue; i < beginValue + size; ++i) {
@@ -228,7 +231,18 @@ auto readVLAValues = [](uint8_t* target, ReadOps& op, ReadOps const& offsetOp, T
228231
rootBuffer.Reset();
229232
while (readEntries < op.rootBranchEntries) {
230233
auto readLast = op.branch->GetBulkRead().GetEntriesSerialized(readEntries, rootBuffer);
234+
if (readLast < 0) {
235+
throw runtime_error_f("Error while reading branch %s starting from %d.", op.branch->GetName(), readEntries);
236+
}
237+
if (readEntries + readLast > op.rootBranchEntries) {
238+
throw runtime_error_f("Invalid read range for branch %s: starting from %d, read %d entries, total entries %lld.",
239+
op.branch->GetName(), readEntries, readLast, static_cast<long long>(op.rootBranchEntries));
240+
}
231241
int size = offsets[readEntries + readLast] - offsets[readEntries];
242+
if (size < 0) {
243+
throw runtime_error_f("Invalid offset range for branch %s: offsets[%d]=%d, offsets[%d]=%d.",
244+
op.branch->GetName(), readEntries, offsets[readEntries], readEntries + readLast, offsets[readEntries + readLast]);
245+
}
232246
readEntries += readLast;
233247
bigEndianCopy(target, rootBuffer.GetCurrent(), size, op.typeSize);
234248
target += (ptrdiff_t)(size * op.typeSize);

0 commit comments

Comments
 (0)