diff --git a/io/io/src/TBufferFile.cxx b/io/io/src/TBufferFile.cxx index a20a67ec60861..b123708aa084d 100644 --- a/io/io/src/TBufferFile.cxx +++ b/io/io/src/TBufferFile.cxx @@ -824,7 +824,10 @@ Int_t TBufferFile::ReadArray(Int_t *&ii) if (ShouldNotReadCollection(l, n)) return 0; - if (!ii) ii = new Int_t[n]; + // Allocate a buffer for this array if the caller hasn't done so. + // Note: Offset arrays require one more element than n claims, so we need to overallocate. + if (!ii) + ii = new Int_t[n + 1]; #ifdef R__BYTESWAP # ifdef USE_BSWAPCPY