Skip to content

Commit 475a56c

Browse files
committed
Zarr V2 multithreaded decoding: avoid potential memory leak / race
Fixes https://issues.oss-fuzz.com/issues/489132118
1 parent 01434ed commit 475a56c

File tree

1 file changed

+9
-3
lines changed

1 file changed

+9
-3
lines changed

frmts/zarr/zarr_v2_array.cpp

Lines changed: 9 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -692,11 +692,17 @@ bool ZarrV2Array::LoadBlockData(const uint64_t *blockIndices, bool bUseMutex,
692692
CPLAssert(psFilterDecompressor);
693693

694694
CPLStringList aosOptions;
695-
for (const auto &obj : oFilter.GetChildren())
695+
696696
{
697-
aosOptions.SetNameValue(obj.GetName().c_str(),
698-
obj.ToString().c_str());
697+
// Below obj.ToString() involves dynamic memory allocation
698+
std::lock_guard<std::mutex> oLock(m_oMutex);
699+
for (const auto &obj : oFilter.GetChildren())
700+
{
701+
aosOptions.SetNameValue(obj.GetName().c_str(),
702+
obj.ToString().c_str());
703+
}
699704
}
705+
700706
void *out_buffer = &abyTmpRawBlockData[0];
701707
size_t nOutSize = abyTmpRawBlockData.size();
702708
if (!psFilterDecompressor->pfnFunc(

0 commit comments

Comments
 (0)