ZEISS/libczi

CSingleChannelTileAccessor::Get() returns uninitialized memory

lschr opened this issue · 0 comments

lschr commented

Describe the bug
CSingleChannelTileAccessor::Get (and probably also the other accessor implementations) returns uninitialized memory if called with pOptions=nullptr or if passing ISingleChannelTileAccessor::Options where backGroundColor has not been set to finite values explicitly. (Note that ISingleChannelTileAccessor::Options::Clear() sets the backGroundColor values to NaN.)

The reason is that CSingleChannelAccessorBase::Clear(), which is called by CSingleChannelTileAccessor::InternalGet() , only fills the bitmap if all values of backGroundColor are not NaN.

To Reproduce

auto reader = libCZI::CreateCZIReader();
reader->open(/* some stream */);
auto accessor = reader->CreateSingleChannelTileAccessor();
libCZI::CDimCoordinate coord;
// set some coordinates
auto bitmap = accessor->Get(/* some ROI which is not fully covered by tiles */, &coords, nullptr);
auto lock_info = bitmap->Lock();
// enjoy random values in regions not covered by tiles
bitmap->Unlock();

Expected behavior
Background pixels are initialized with a predictable value by default.

Desktop (please complete the following information):

  • OS: Linux