Skip to content

Commit

Permalink
fixed SparseVolume::alloc when reallocating a copy of a volume which …
Browse files Browse the repository at this point in the history
…doesn't own its data

in this case we force a more "regular" allocator, otherwise the volume
is not allocated and the program crashes (#98).
  • Loading branch information
denisri committed May 12, 2023
1 parent 345dd5e commit 8e1ace7
Showing 1 changed file with 8 additions and 0 deletions.
8 changes: 8 additions & 0 deletions aimsdata/src/aimsdata/bucket/sparsevolume.h
Original file line number Diff line number Diff line change
Expand Up @@ -517,6 +517,14 @@ namespace aims
break;
}
}
std::unique_ptr<carto::AllocatorContext> pac;
if( ac->allocatorType() == carto::AllocatorStrategy::Unallocated )
{
// if src is unallocated (does not own its data), we still need to
// allocate a volume.
pac.reset( new carto::AllocatorContext );
ac = pac.get();
}
carto::Volume<T> *data = new carto::Volume<T>( src.getSizeX(),
src.getSizeY(), src.getSizeZ(), src.getSizeT(), *ac );
data->copyHeaderFrom( src.header() );
Expand Down

0 comments on commit 8e1ace7

Please sign in to comment.