Fix out-of-bounds read when looking for subtitles in a matroska file with no subtitles

This commit is contained in:
Thomas Goyne 2014-03-28 09:15:09 -07:00
parent c1f968a252
commit dbec5ff0bc
1 changed files with 4 additions and 0 deletions

View File

@ -67,6 +67,10 @@ struct MkvStdIO final : InputStream {
if (pos == self->file.size())
return 0;
auto remaining = self->file.size() - pos;
if (remaining < INT_MAX)
count = std::min(static_cast<int>(remaining), count);
try {
memcpy(buffer, self->file.read(pos, count), count);
}