diff --git a/src/MatroskaParser.c b/src/MatroskaParser.c index 176d136482..9983911af7 100644 --- a/src/MatroskaParser.c +++ b/src/MatroskaParser.c @@ -2250,7 +2250,7 @@ static void parseBlockGroup(MatroskaFile *mf,uint64_t toplen,uint64_t timecode, // we want to still load these bytes into cache for (v = filepos(mf) & ~0x3fff; v < len + dpos; v += 0x4000) - mf->cache->read(mf->cache,v,NULL,0); // touch page + mf->cache->read(mf->cache,v,NULL,0); // touch page (FIXME this doesn't really do anything) skipbytes(mf,len - filepos(mf) + dpos); diff --git a/src/mkv_wrap.cpp b/src/mkv_wrap.cpp index 9eed3b704e..e0f69972a4 100644 --- a/src/mkv_wrap.cpp +++ b/src/mkv_wrap.cpp @@ -69,8 +69,13 @@ struct MkvStdIO final : InputStream { if (remaining < INT_MAX) count = std::min(static_cast(remaining), count); + if (count <= 0) + return 0; + try { - memcpy(buffer, self->file.read(pos, count), count); + auto data = self->file.read(pos, count); + if (buffer) + memcpy(buffer, data, count); } catch (agi::Exception const& e) { self->error = e.GetMessage();