From d5535a198f93052a2875969b59cf8eb447704210 Mon Sep 17 00:00:00 2001 From: Filip Hejsek Date: Mon, 2 Mar 2026 17:44:57 +0100 Subject: [PATCH 1/2] Fix calling memcpy with a null pointer from MatroskaParser This change was originally authored by mojie126@foxmail.com --- src/mkv_wrap.cpp | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) 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(); From ab24b3f5f98852f1a504b36f30cb66527481d890 Mon Sep 17 00:00:00 2001 From: Filip Hejsek Date: Mon, 2 Mar 2026 17:31:24 +0100 Subject: [PATCH 2/2] Add FIXME to MatroskaParser --- src/MatroskaParser.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) 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);